Skip to content

fix: Align FindName behavior with WinUI - #16177

Closed
Youssef1313 wants to merge 10 commits into
unoplatform:masterfrom
Youssef1313:findname
Closed

Youssef1313 wants to merge 10 commits into
unoplatform:masterfrom
Youssef1313:findname

Conversation

@Youssef1313

@Youssef1313 Youssef1313 commented Apr 8, 2024 •

Copy link
Copy Markdown
Member

GitHub Issue (If applicable): closes #7043 closes #14663

PR Type

What kind of change does this PR introduce?

What is the current behavior?

What is the new behavior?

PR Checklist

Please check if your PR fulfills the following requirements:

Other information

Internal Issue (If applicable):

@github-actions github-actions Bot added platform/wasm 🌐 Categorizes an issue or PR as relevant to the WebAssembly platform area/skia ✏️ Categorizes an issue or PR as relevant to Skia area/automation Categorizes an issue or PR as relevant to project automation labels Apr 8, 2024
@Youssef1313 Youssef1313 changed the title Findname fix: Align FindName behavior with WinUI Apr 8, 2024
@github-actions github-actions Bot added platform/android 🤖 Categorizes an issue or PR as relevant to the Android platform platform/macos 🍏 Categorizes an issue or PR as relevant to the macOS platform platform/ios 🍎 Categorizes an issue or PR as relevant to the iOS platform labels Apr 8, 2024
@unodevops

Copy link
Copy Markdown
Contributor

@unodevops

Copy link
Copy Markdown
Contributor

@unodevops

Copy link
Copy Markdown
Contributor

@unodevops

Copy link
Copy Markdown
Contributor

@unodevops

Copy link
Copy Markdown
Contributor

@unodevops

Copy link
Copy Markdown
Contributor

@unodevops

Copy link
Copy Markdown
Contributor

@unodevops

Copy link
Copy Markdown
Contributor

@unodevops

Copy link
Copy Markdown
Contributor

@Youssef1313

Copy link
Copy Markdown
Member Author

When continuing fixing FindName, make sure to test this scenario:

MainWindow.xaml:

<Window
    x:Class="App6.MainWindow"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:local="using:App6"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    mc:Ignorable="d">

    <StackPanel x:Name="inWindow1">
        <Button x:Name="inWindow2" />
        <local:MyComponent x:Name="inWindow3" />
    </StackPanel>
</Window>

MyComponent.xaml:

<Page
    x:Class="App6.MyComponent"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:local="using:App6"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    mc:Ignorable="d"
    Background="{ThemeResource ApplicationPageBackgroundThemeBrush}" x:Name="componentRoot">

    <Grid x:Name="inComponent1" x:FieldModifier="public">
        <Button x:Name="inComponent2" x:FieldModifier="public" />
    </Grid>
</Page>

MainWindow.xaml.cs:

using System;
using Microsoft.UI.Xaml;
using Microsoft.UI.Xaml.Controls;
using Microsoft.UI.Xaml.Data;
using Microsoft.UI.Xaml.Markup;

namespace App6;

public sealed partial class MainWindow : Window
{
    public MainWindow()
    {
        this.InitializeComponent();
        this.inWindow1.Loaded += InWindow1_Loaded;
    }

    private void InWindow1_Loaded(object sender, RoutedEventArgs e)
    {
        var x1 = inWindow1.FindName("inWindow1");
        var x2 = inWindow1.FindName("inWindow2");
        var x3 = inWindow1.FindName("inWindow3");
        var x4 = inWindow1.FindName("componentRoot");
        var x5 = inWindow1.FindName("inComponent1");
        var x6 = inWindow1.FindName("inComponent2");

        var y1 = inWindow2.FindName("inWindow1");
        var y2 = inWindow2.FindName("inWindow2");
        var y3 = inWindow2.FindName("inWindow3");
        var y4 = inWindow2.FindName("componentRoot");
        var y5 = inWindow2.FindName("inComponent1");
        var y6 = inWindow2.FindName("inComponent2");


        var z1 = inWindow3.FindName("inWindow1");
        var z2 = inWindow3.FindName("inWindow2");
        var z3 = inWindow3.FindName("inWindow3");
        var z4 = inWindow3.FindName("componentRoot");
        var z5 = inWindow3.FindName("inComponent1");
        var z6 = inWindow3.FindName("inComponent2");

        var a1 = inWindow3.inComponent1.FindName("inWindow1");
        var a2 = inWindow3.inComponent1.FindName("inWindow2");
        var a3 = inWindow3.inComponent1.FindName("inWindow3");
        var a4 = inWindow3.inComponent1.FindName("componentRoot");
        var a5 = inWindow3.inComponent1.FindName("inComponent1");
        var a6 = inWindow3.inComponent1.FindName("inComponent2");

        var b1 = inWindow3.inComponent1.FindName("inWindow1");
        var b2 = inWindow3.inComponent1.FindName("inWindow2");
        var b3 = inWindow3.inComponent1.FindName("inWindow3");
        var b4 = inWindow3.inComponent1.FindName("componentRoot");
        var b5 = inWindow3.inComponent1.FindName("inComponent1");
        var b6 = inWindow3.inComponent1.FindName("inComponent2");
    }
}

MyComponent.xaml.cs:

using Microsoft.UI.Xaml.Controls;

namespace App6;

public sealed partial class MyComponent : Page
{
	public MyComponent()
	{
		this.InitializeComponent();
	}
}

@github-actions

github-actions Bot commented Feb 3, 2025

Copy link
Copy Markdown
Contributor

This PR is stale because it has been open 60 days with no activity. Remove stale label or comment or it will be closed in 10 days.

@github-actions github-actions Bot added the stale This item has been marked as stale and will be closed if there is no activity. label Feb 3, 2025
@github-actions

Copy link
Copy Markdown
Contributor

This PR was closed because it has been stalled for 10 days with no activity.

@github-actions github-actions Bot closed this Feb 13, 2025
@Youssef1313 Youssef1313 mentioned this pull request Jul 25, 2025
1 of 2 tasks
@MartinZikmund MartinZikmund removed the stale This item has been marked as stale and will be closed if there is no activity. label Jun 22, 2026
@MartinZikmund MartinZikmund reopened this Jun 22, 2026
@github-actions

Copy link
Copy Markdown
Contributor

This PR is stale because it has been open 60 days with no activity. Remove stale label or comment or it will be closed in 10 days.

@github-actions github-actions Bot added the stale This item has been marked as stale and will be closed if there is no activity. label Aug 22, 2026
@github-actions

github-actions Bot commented Sep 2, 2026

Copy link
Copy Markdown
Contributor

This PR was closed because it has been stalled for 10 days with no activity.

@github-actions github-actions Bot closed this Sep 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/automation Categorizes an issue or PR as relevant to project automation area/skia ✏️ Categorizes an issue or PR as relevant to Skia platform/android 🤖 Categorizes an issue or PR as relevant to the Android platform platform/ios 🍎 Categorizes an issue or PR as relevant to the iOS platform platform/macos 🍏 Categorizes an issue or PR as relevant to the macOS platform platform/wasm 🌐 Categorizes an issue or PR as relevant to the WebAssembly platform stale This item has been marked as stale and will be closed if there is no activity.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

FindName(..) only finds elements in the subtree of the element it is called on. FrameworkElement.FindName doesn't look for resources

3 participants