I have in my Model (Class X) Boolean property: IsSelected
, is linked to a WPF DataGrid
as follows:
<DataGrid SelectedIndex="{Binding SelectedXIndex,Mode=TwoWay}"
DataContext="{Binding MyViewModel}"
ItemsSource="{Binding ListX}" AutoGenerateColumns="False">
<DataGrid.RowStyle>
<Style TargetType="{x:Type DataGridRow}">
<Setter Property="IsSelected"
Value="{Binding IsSelected, Mode=TwoWay,
UpdateSourceTrigger=PropertyChanged}"/>
</Style>
</DataGrid.RowStyle>
</DataGrid>
ListX
- ObservableCollection
IsSelecte
- Call to NotifyPropertyChange
It works great.
But when I have a lot of rows, that I need to scroll to see them, and I press the button "Select All" that runs the following function, he chooses me only some of the rows and not all: (Even though all the IsSelected on the list is true)
public void SelectAll()
{
ListX.All(c => c.IsSelected = true);
}
I can not understand why this is happening?
that's what helped me finally:
I put in the DataGrid:
VirtualizingStackPanel.VirtualizationMode="Standard"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With