raze
Topic Author
Posts: 6
Joined: 05 Jun 2025, 22:36

Crash when updating ItemsControl using VirtualizingWrapPanel + ScrollViewer

10 Jan 2026, 20:37

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
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}");
            }
        });
    }
}

Xaml:
<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>
 
raze
Topic Author
Posts: 6
Joined: 05 Jun 2025, 22:36

Re: Crash when updating ItemsControl using VirtualizingWrapPanel + ScrollViewer

10 Jan 2026, 23:42

A workaround for now would be to scroll to top before changing items (which is better UX anyway).
 
User avatar
dstewart
Site Admin
Posts: 133
Joined: 22 Jan 2024, 11:41

Re: Crash when updating ItemsControl using VirtualizingWrapPanel + ScrollViewer

12 Jan 2026, 14:56

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
 
User avatar
jsantos
Site Admin
Posts: 4822
Joined: 20 Jan 2012, 17:18
Contact:

Re: Crash when updating ItemsControl using VirtualizingWrapPanel + ScrollViewer

19 Jan 2026, 21:20

Fixed for the upcoming 3.2.11

Who is online

Users browsing this forum: Bing [Bot], Google [Bot] and 9 guests