We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
FindName()
FindName() does not work in WinUI3, while the exact same code works in UWP.
<StackPanel x:Name="Root" Orientation="Vertical" HorizontalAlignment="Center" VerticalAlignment="Center" Spacing="5"> <Button x:Name="myButton" Click="myButton_Click">Click to load</Button> <Rectangle x:Name="DelayLoadRect" Fill="Green" Width="100" Height="50" x:Load="False" Loaded="Rectangle_Loaded"/> </StackPanel>
void MainWindow::myButton_Click(IInspectable const&, RoutedEventArgs const&) { static bool IsLoaded = false; if (IsLoaded) { winrt::Microsoft::UI::Xaml::Markup::XamlMarkupHelper::UnloadObject(DelayLoadRect()); myButton().Content(box_value(L"Click to load")); } else { myButton().Content(box_value(L"Click to unload")); auto delayLoadRect = Root().FindName(L"DelayLoadRect"); } IsLoaded = !IsLoaded; } void MainWindow::Rectangle_Loaded(winrt::Windows::Foundation::IInspectable const& sender, winrt::Microsoft::UI::Xaml::RoutedEventArgs const& e) { winrt::Microsoft::UI::Xaml::Controls::ContentDialog dialog; dialog.XamlRoot(Content().XamlRoot()); dialog.Title(winrt::box_value(L"Loaded")); dialog.PrimaryButtonText(L"OK"); dialog.ShowAsync(); }
Repro here
No response
WinUI 3 - Windows App SDK 1.5.5: 1.5.240627000
Windows 11 (22H2): Build 22621
The text was updated successfully, but these errors were encountered:
Try it on a page instead.
Sorry, something went wrong.
Moving it to a Page does work, but I think the fact that it does not work under Window needs to be documented.
Page
Window
No branches or pull requests
Describe the bug
FindName()
does not work in WinUI3, while the exact same code works in UWP.Steps to reproduce the bug
Repro here
Expected behavior
No response
Screenshots
No response
NuGet package version
WinUI 3 - Windows App SDK 1.5.5: 1.5.240627000
Windows version
Windows 11 (22H2): Build 22621
Additional context
No response
The text was updated successfully, but these errors were encountered: