I'm trying to get all row selected in a datagrid. All row are an item of an ObservableCollection<T>
, and I would like to know which elements are, or not, selected (could be one, lots or none). Also, I don't want to use a checkbox, would like (if possible) somethink like ctrl + leftMouseClick so select multiple rows.
Here is the xaml code :
<DataGrid ItemsSource="{Binding ListBinded}" AutoGenerateColumns="False" Name="ListName"
Style="{StaticResource AzureDataGrid}" Grid.Row="1" FrozenColumnCount="2"
ScrollViewer.CanContentScroll="True" ScrollViewer.VerticalScrollBarVisibility="Visible" ScrollViewer.HorizontalScrollBarVisibility="Auto">
<DataGrid.Resources>
<Style x:Key="AlignBottomColumnHeader" BasedOn="{StaticResource AzureDataGridColumnHeader}" TargetType="DataGridColumnHeader">
<Setter Property="VerticalContentAlignment" Value="Bottom" />
</Style>
</DataGrid.Resources>
<DataGrid.Columns>
<!--Description-->
<DataGridTemplateColumn Header="Description" HeaderStyle="{StaticResource AlignBottomColumnHeader}" Width="*" MinWidth="200">
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<Border BorderThickness="2">
<TextBlock Text="{Binding InfoColumn}"/>
</Border>
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>
</DataGrid.Columns>
</DataGrid>
Would love to put the C# code below, but there is no code for now.
EDIT: For me it's not a duplicate, because I don't have a DataGrid in my code below but a ObservableCollection, which does not have a SelectedItem parameter (i'm trying to get the informations in the ViewModelBase class, after an ICommand triggered)