-
Notifications
You must be signed in to change notification settings - Fork 677
New issue
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
App freezes with ItemsPresenter + UniformGridLayout + Binding in ItemTemplate #6689
Comments
This works fine: <ItemsRepeater ItemsSource="{x:Bind Items}">
<ItemsRepeater.Layout>
<UniformGridLayout />
</ItemsRepeater.Layout>
<ItemsRepeater.ItemTemplate>
<DataTemplate x:DataType="local:Item">
<TextBlock Text="{x:Bind Text}" />
</DataTemplate>
</ItemsRepeater.ItemTemplate>
</ItemsRepeater> public sealed class Item
{
public string Text { get; set; }
}
public sealed partial class MainWindow : Window
{
public MainWindow()
{
this.InitializeComponent();
}
public Item[] Items { get; } = new[]
{
new Item() { Text = "foo" },
new Item() { Text = "bar" },
};
} |
@kmgallahan, are you saying that the bug is no repro or that |
I can repro the original issue. My first thought when seeing problems with |
Thanks kmgallahan! @fabiant3 FYI on the Binding issue. |
I've run into a similar bug while using ItemsRepeater.ItemTemplate attribute : This code freezes:
I found this workaround :
|
I can reproduce the issue, swapped x:bind to binding and it wouldn't help... Its crazy that this still persists after a year, how very disappointing. |
I've also run into a similar bug on my side while using muxc:ItemsRepeater + muxc:UniformGridLayout + Binding in ItemTemplate. |
We investigated the issue with @agneszitte-nventive and we found that indeed there is a layout cycling issue related to bindings: IR is measuring again and again the same item, but measured size returned by the item changes (Depending if binding are applied or not yet? Appears also that bindings can be reset ... does item is detached from visual tree / data-context cleared by IR while it measures the first item?) Removing bindings in the template OR fixing the size of the root element does "fix" the issue ... but it's not responsive and defeats the main purpose of the A better work-around is then to "stabilize" the size of the root element, especially on the "non scrolling / wrapping axis" (i.e. horizontally in common usage). For this we altered the measure of the root element (created a protected override Size MeasureOverride(Size availableSize)
=> new Size(availableSize.Width, base.MeasureOverride(availableSize).Height); We also made sure to remove all sizing constraints on that element (for instance, we removed |
I can confirm that using |
I have not been able to reproduce this with the WinAppSDK version 1.5.240428000, so closing this issue for now. |
Describe the bug
Using a trivial combination of
<ItemsPresenter>
,<UniformGridLayout>
and anItemTemplate
with a{Binding}
, my app freezes. If I pause the execution in the debugger, WinUI seems to be stuck executing the UniformGridLayout measure phase:Steps to reproduce the bug
Blank App, Packaged (WinUI 3 in Desktop)
app.MainWindow.xaml
:Expected behavior
The app shows "foo bar" and is responsive.
Screenshots
No response
NuGet package version
WinUI 3 - Windows App SDK 1.0 (If you're seeing your issue in older previews of WinUI 3, please try this release)
Windows app type
Device form factor
Desktop
Windows version
No response
Additional context
Windows 11, v21H2, 22000.434
The text was updated successfully, but these errors were encountered: