VirtualizingStackPanel + MVVM + multiple selection

I found another way of handling selection in the MVVM pattern, which solved my issue. Instead of maintaining the selection in the viewmodel, the selection is retrieved from the ListView/ListBox, and passed as a parameter to the Command. All done in XAML: <ListView x:Name=”_items” ItemsSource=”{Binding Items}” … /> <Button Content=”Remove Selected” Command=”{Binding RemoveSelectedItemsCommand}” CommandParameter=”{Binding ElementName=_items, … Read more

Virtualizing an ItemsControl?

There’s actually much more to it than just making the ItemsPanelTemplate use VirtualizingStackPanel. The default ControlTemplate for ItemsControl does not have a ScrollViewer, which is the key to virtualization. Adding to the the default control template for ItemsControl (using the control template for ListBox as a template) gives us the following: <ItemsControl ItemsSource=”{Binding AccountViews.Tables[0]}”> <ItemsControl.ItemTemplate> … Read more