I am pretty new to C# MVVM, WPF . I have a DataGrid in which I can select Multiple Rows, I wanted to get the value of multiple rows as an Array of Objects. I have seen the links like this but could not find what I want Exactly.
enter code here
<DataGrid ScrollViewer.CanContentScroll="True" VerticalScrollBarVisibility="Auto" SelectionUnit="FullRow" BorderThickness="1" x:Name="ssa" CanUserAddRows="False" CanUserDeleteRows="False" AutoGenerateColumns="False" ItemsSource="{Binding Items,UpdateSourceTrigger=PropertyChanged}" IsSynchronizedWithCurrentItem="True" GridLinesVisibility="All"
HorizontalScrollBarVisibility="Auto" SelectionMode="Single" Height="280" Width="1600" SelectedItem="{Binding selected_row}">
<DataGrid.ContextMenu>
<ContextMenu>
<MenuItem Header="Get item" Command="{Binding get_item}" CommandParameter="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type ContextMenu}}, Path=PlacementTarget.SelectedItems}">
</MenuItem>
<DataGrid.Columns>
<DataGridTextColumn Width="150" x:Name="item_name" Binding="{Binding name, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged,ValidatesOnDataErrors=True}" FocusManager.FocusedElement="{Binding RelativeSource={RelativeSource Self}}">
Viewmodel.cs binding for the datagrid item is given: private string Name;
public string name
{
get { return Name; }
set { Name = value; RaisePropertyChanged("name"); }
}
enter code here
for the selected item also binding is given, but I am not getting How to get value multiple selected rows of data grid as an Array of Objects