How to get multiple Selected Items (rows) on WPF DataGrid?
I can get only one selected item using SelectedItem attrubure.
XAML:
<Window x:Class="WpfDataGridTest.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<Grid>
<DataGrid ItemsSource="{Binding Items}"
SelectedItem="{Binding SelectedItem}">
</DataGrid>
</Grid>
</Window>
ViewModel:
public class MainViewModel
{
public MainViewModel(IEnumerable<Customer> customers)
{
Items = new ObservableCollection<Customer>(customers);
}
public ObservableCollection<Customer> Items { get; }
public Customer SelectedItem { get; set; }
}
If I select several rows, then SelectedItem stay without changes. How to get multiple selected items?