Crash when updating ItemsControl using VirtualizingWrapPanel + ScrollViewer
Noesis crashes when Items are updated when using a VirtualizingWrapPanel with an ItemsControl and ScrollViewer.
Steps to reproduce:
1. Scroll down viewer
2. Click "Filter" button
ViewModel
Xaml:
Steps to reproduce:
1. Scroll down viewer
2. Click "Filter" button
ViewModel
Code: Select all
public class ViewModel
{
public ObservableCollection<string> Items { get; } = new();
public DelegateCommand FilterItems { get; private set; }
public ViewModel()
{
for (var i = 0; i < 100; i++)
{
Items.Add($"Item {i}");
}
FilterItems = new DelegateCommand(_ =>
{
Items.Clear();
for (var i = 0; i < 10; i++)
{
Items.Add($"Filtered Item {i}");
}
});
}
}
Code: Select all
<Grid Width="400" Height="400">
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<Button Command="{Binding FilterItems}">Filter</Button>
<ItemsControl
Grid.Row="1"
Width="300"
Height="300"
ItemsSource="{Binding Items}"
VirtualizingPanel.IsVirtualizing="True"
VirtualizingPanel.ScrollUnit="Pixel"
>
<ItemsControl.Template>
<ControlTemplate TargetType="ItemsControl">
<ScrollViewer
Background="Transparent"
CanContentScroll="True"
Focusable="False"
HorizontalScrollBarVisibility="Disabled"
>
<ItemsPresenter />
</ScrollViewer>
</ControlTemplate>
</ItemsControl.Template>
<ItemsControl.ItemsPanel>
<ItemsPanelTemplate>
<VirtualizingWrapPanel />
</ItemsPanelTemplate>
</ItemsControl.ItemsPanel>
<ItemsControl.ItemTemplate>
<DataTemplate>
<Border Width="100" Height="100" Margin="10" Background="Red">
<TextBlock
HorizontalAlignment="Center"
VerticalAlignment="Center"
Foreground="White"
Text="{Binding}"
/>
</Border>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
</Grid>
Re: Crash when updating ItemsControl using VirtualizingWrapPanel + ScrollViewer
A workaround for now would be to scroll to top before changing items (which is better UX anyway).
Re: Crash when updating ItemsControl using VirtualizingWrapPanel + ScrollViewer
Hi Raze,
Thanks for dropping by and reporting this crash.
I've created a ticket for our team to investigate this, which you can follow at #4690.
- Dorian
Thanks for dropping by and reporting this crash.
I've created a ticket for our team to investigate this, which you can follow at #4690.
- Dorian
Re: Crash when updating ItemsControl using VirtualizingWrapPanel + ScrollViewer
Fixed for the upcoming 3.2.11
Who is online
Users browsing this forum: Bing [Bot], Google [Bot] and 9 guests