i want to get the selected row of datagrid i.e on click in mvvm.i have below code i want to use it in MVVM,but not able to do so.Please let me know how to convert below 3 line s in mvvm using relay comand and Icommand
DataRowView dataRow = (DataRowView)dgProjectComponents.SelectedItem;
int index = dgProjectComponents.CurrentCell.Column.DisplayIndex;
string ProjectComponentID = Convert.ToString(dataRow.Row.ItemArray[2].ToString());
**Xaml of datagrid:**
<DataGrid SelectedItem="{Binding SelectedRow}" Background="{Binding ElementName=gd,Path=Background}" ItemsSource="{Binding ManualDataTable}" x:Name="dgProjectComponents">
<DataGrid.Columns>
<DataGridTemplateColumn Width="50" IsReadOnly="True">
<DataGridTemplateColumn.CellTemplate>
<DataTemplate >
<TextBlock Height="10" Width="10" Background="{Binding ColorDefinition}" ></TextBlock>
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>
<DataGridTextColumn Binding="{Binding ProjectComponentID}" Visibility="Hidden" Width="100" Header="ProjectComponentID" />
<DataGridTextColumn Binding="{Binding Title}" IsReadOnly="True" Width="140" />
<DataGridTemplateColumn Width="50">
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<TextBlock><Hyperlink Command="{Binding Path=DataContext.DelProjectComponent,ElementName=ProjectTabWindow}"><Image Source="/img/Close.png" x:Name="imgProjectComponentDelete" Height="15" Width="20"></Image></Hyperlink></TextBlock>
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>
</DataGrid.Columns>
</DataGrid>
</DataGrid>