Repository navigation
Description
Current behavior
If you call FindName("elementName") on a framework element in the XAML tree, on Android and WASM it will succeed if the target element is in the subtree of the element it is called on, but not if it is somewhere else in the XAML tree. By contrast, on Windows FindName(..) finds elements in the entire page, or at least in the whole content under a ContentPresenter.
Expected behavior
Same behavior as on Windows. See above.
How to reproduce it (as minimally and precisely as possible)
The reduced repro is here: UnoApp10.zip
I have the following XAML:
<StackPanel HorizontalAlignment="Center" VerticalAlignment="Center">
<Grid>
<Button Content="Click me!" Click="On_Button_Clicked"/>
</Grid>
<TextBlock x:Name="MyTextBlock" Height="400" Width="400"/>
</StackPanel>
And code that runs FindName(..) on the Button, the Grid, and the StackPanel, logging success of failure in MyTextBlock:
private void On_Button_Clicked(object sender, RoutedEventArgs e)
{
var button = (sender as Button)!;
TryFindTextBlock(button, "Button");
var grid = (button.Parent as Grid)!;
TryFindTextBlock(grid, "Grid");
var stackPanel = (grid.Parent as StackPanel)!;
TryFindTextBlock(stackPanel, "StackPanel");
}
private void TryFindTextBlock(FrameworkElement fromElement, string elementName)
{
var tb = fromElement.FindName("MyTextBlock");
if (tb != null)
{
(tb as TextBlock)!.Text += $"FindName(..) on the {elementName} found MyTextBlock\n";
}
else
{
MyTextBlock.Text += $"FindName(..) on the {elementName} did NOT find MyTextBlock\n";
}
}
Workaround
Walk up the tree manually and call FindName on the topmost reachable ancestor.
Works on UWP/WinUI
None
Environment
No response
NuGet package version(s)
<PackageVersion Include="Microsoft.Extensions.Logging.Console" Version="7.0.0" />
<PackageVersion Include="Microsoft.Windows.Compatibility" Version="7.0.5" />
<PackageVersion Include="Microsoft.Windows.SDK.BuildTools" Version="10.0.22621.756" />
<PackageVersion Include="Microsoft.WindowsAppSDK" Version="1.4.231008000" />
<PackageVersion Include="Uno.Core.Extensions.Logging.Singleton" Version="4.0.1" />
<PackageVersion Include="Uno.Extensions.Logging.OSLog" Version="1.7.0" />
<PackageVersion Include="Uno.Extensions.Logging.WebAssembly.Console" Version="1.7.0" />
<PackageVersion Include="Uno.Resizetizer" Version="1.2.1" />
<PackageVersion Include="Uno.UI.Adapter.Microsoft.Extensions.Logging" Version="5.0.64" />
<PackageVersion Include="Uno.UniversalImageLoader" Version="1.9.36" />
<PackageVersion Include="Uno.Wasm.Bootstrap" Version="8.0.4" />
<PackageVersion Include="Uno.Wasm.Bootstrap.DevServer" Version="8.0.4" />
<PackageVersion Include="Uno.Wasm.Bootstrap.Server" Version="8.0.4" />
<PackageVersion Include="Uno.WinUI" Version="5.0.64" />
<PackageVersion Include="Uno.WinUI.Lottie" Version="5.0.64" />
<PackageVersion Include="Uno.WinUI.DevServer" Version="5.0.64" />
<PackageVersion Include="Uno.WinUI.WebAssembly" Version="5.0.64" />
<PackageVersion Include="Xamarin.Google.Android.Material" Version="1.10.0.1" />
Affected platforms
WebAssembly, Android
IDE
Visual Studio 2022
IDE version
VS 17.7.6
Relevant plugins
No response
Anything else we need to know?
I did not test it, but presuming the behavior is the same on iOS.


Activity
jeromelaban commentedon Dec 5, 2023
Thanks for the report.
This is something we built as a best effort, but now with the WinUI sources available, we'll be able to make a more accurate implementation.
MartinZikmund commentedon Jul 23, 2025
#21129
FindNamewith WinUI #21129github-actions commentedon May 3, 2026
This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs or feature requests.