uno icon indicating copy to clipboard operation
uno copied to clipboard

[Desktop] FindName returns null when searching for Layout

Open kucint opened this issue 4 months ago • 1 comments

Current behavior

FindName() fails to find ItemsRepeater on Desktop. It works fine on WinAppSDK.

<Grid>
  <ItemsRepeater>
    <ItemsRepeater.Layout>
      <StackLayout x:Name="MyLayout"/>
    </ItemsRepeater.Layout>
  </ItemsRepeater>
  <Button
    Content="Click me"
    Click="Button_Click"
    HorizontalAlignment="Center" />
</Grid>
public sealed partial class MainPage : Page
{
    public MainPage()
    {
        this.InitializeComponent();
    }

    private void Button_Click(object sender, RoutedEventArgs e)
    {
        var myElement = FindName("MyLayout");
    }
}

Expected behavior

FindName() shall find ItemsRepeater on Desktopas it does onWinAppSDK`

How to reproduce it (as minimally and precisely as possible)

MINIMAL REPRO PROJECT: UnoFindNameApp.zip

STEPS TO REPRODUCE:

  • Run the app
  • place a breakpoint on Button_Click
  • click the button
  • investigate var myElement = FindName("MyLayout");
  • myElement is null on Desktop but contains correct value on WinAppSDK

Workaround

No response

Works on UWP/WinUI

Yes

Environment

No response

NuGet package version(s)

"Uno.Sdk": "5.4.10"

Affected platforms

Skia (WPF)

IDE

Visual Studio 2022

IDE version

No response

Relevant plugins

No response

Anything else we need to know?

No response

kucint avatar Oct 10 '24 11:10 kucint