You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
With C# Markup using a NonVirtualizingLayout seems to be wrapping its ItemTemplate content inside a Grid on WinUI. I tried reproducing this issue with Xaml and I can't reproduce the same behavior with similar layout.
C# Markup Details
Create ItemsRepeater that is populated with items of type TextBlock
publicMainPage(){this.Background(ThemeResource.Get<Brush>("ApplicationPageBackgroundThemeBrush")).Content(newStackPanel().VerticalAlignment(VerticalAlignment.Center).HorizontalAlignment(HorizontalAlignment.Center).Children(newTextBlock().HorizontalAlignment(HorizontalAlignment.Center).Text("Hello Uno Platform!"),newItemsRepeater()//.Layout(new StackLayout()) // works fine.Layout(newMyLayout())// works fine, using my layout let me to inspect created items.HorizontalAlignment(HorizontalAlignment.Center).ItemsSource(Enumerable.Range(0,5)).ItemTemplate<int>(item =>newTextBlock().HorizontalAlignment(HorizontalAlignment.Center).Text(()=>$"Item {item}"))));}
This works fine under Desktop and Windows, however in both cases created items differ.
Using my own layout let me to inspect created items:
publicclassMyLayout:NonVirtualizingLayout{protectedoverrideSizeMeasureOverride(NonVirtualizingLayoutContextcontext,SizeavailableSize){doubleextentHeight=0.0;doubleextentWidth=0.0;foreach(UIElementelementincontext.Children){element.Measure(availableSize);extentHeight+=element.DesiredSize.Height;extentWidth=Math.Max(extentWidth,element.DesiredSize.Width);}returnnewSize(extentWidth,extentHeight);}protectedoverrideSizeArrangeOverride(NonVirtualizingLayoutContextcontext,SizefinalSize){doubleoffset=0.0;foreach(FrameworkElementelementincontext.Children.Cast<FrameworkElement>()){element.Arrange(newRect(0,offset,element.DesiredSize.Width,element.DesiredSize.Height));offset+=element.DesiredSize.Height;// inspect the type of elementDebug.WriteLine($"element type: {element.GetType().Name}");Debug.WriteLine($"element.DataContext: {element.DataContext}");}returnfinalSize;}}
Surprisingly the type of element differs between Desktop and Windows:
Desktop : type is TextBlock as expected
Windows: type is Grid. This grid contains one single element of type TextBlock which is the expected one.
The Grid is redundant under Windows, its origin is unknown. I do not use Grid in my code at all.
With C# Markup using a
NonVirtualizingLayout
seems to be wrapping its ItemTemplate content inside a Grid on WinUI. I tried reproducing this issue with Xaml and I can't reproduce the same behavior with similar layout.C# Markup Details
Create
ItemsRepeater
that is populated with items of typeTextBlock
This works fine under
Desktop
andWindows
, however in both cases created items differ.Using my own layout let me to inspect created items:
Surprisingly the type of element differs between
Desktop
andWindows
:Desktop
: type isTextBlock
as expectedWindows
: type isGrid
. This grid contains one single element of typeTextBlock
which is the expected one.The
Grid
is redundant underWindows
, its origin is unknown. I do not useGrid
in my code at all."Uno.Sdk": "5.4.0-dev.99"
Xaml Details
repro: UnoNonVirtualizingLayoutWrongItemTypeApp.zip
Originally posted by @kucint in #2416
The text was updated successfully, but these errors were encountered: