I want to be able to select multiple rows in this DataGrid, then retrieve the data present in the selected cells. Everything I have found online isn't working. I've tried to use event arguments like 'SelectionChanged' and 'SelectedCellsChanged' to get the rows index, but it doesn't behave in a manner that allows me to keep track of all the rows that are selected.
Is anyone able to suggest a way of doing this? Thanks in advance.
DataGrid code:
<DataGrid x:Name="walkGrd" ItemsSource="{Binding overviewGrd}" RowHeaderWidth="0" AutoGenerateColumns="True" ColumnWidth="*" CanUserAddRows="False" CanUserDeleteRows="False" CanUserReorderColumns="False" CanUserSortColumns="False" IsReadOnly="True" SelectionMode="Extended" SelectionUnit="FullRow" Margin="1,63,0,37" RowHeight="18" FontSize="13" BorderBrush="Black" AreRowDetailsFrozen="True">
<DataGrid.Resources>
<Style TargetType="{x:Type DataGridCell}">
<Setter Property="BorderThickness" Value="0"/>
<Setter Property="Margin" Value="0,0,-1,0"/>
<Setter Property="FocusVisualStyle" Value="{x:Null}"/>
<Style.Triggers>
<Trigger Property="IsSelected" Value="True">
<Setter Property="Background" Value="DarkGray"/>
<Setter Property="Foreground" Value="White"/>
</Trigger>
</Style.Triggers>
</Style>
<Style x:Key="Body_Content_DataGrid_Centering"
TargetType="{x:Type DataGridCell}">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type DataGridCell}">
<Grid Background="{TemplateBinding Background}">
<ContentPresenter VerticalAlignment="Center" />
</Grid>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</DataGrid.Resources>
<DataGrid.Columns>
<DataGridTextColumn Header="Identifier" TextBlock.TextAlignment="Justify" Binding="{Binding one}" Width="0.25*" />
<DataGridTextColumn Header="ID OID" Binding="{Binding two}" Width="0.25*" />
<DataGridTextColumn Header="Up Time" Binding="{Binding three}" Width="0.25*" />
<DataGridTextColumn Header="Time OID" Binding="{Binding four}" Width="0.25*" />
</DataGrid.Columns>
</DataGrid>