I get the DataTable from the database, then fill it with the DataGrid :
public ICollectionView Item { get { return (ICollectionView)GetValue(ItemProperty); } set { SetValue(ItemProperty, value); } } public static readonly DependencyProperty ItemProperty = DependencyProperty.Register("Item", typeof(ICollectionView), typeof(ViewModel), new PropertyMetadata(null)); public ViewModel() { database = new DBModel(); data = database.GetDataTableProducts(); Item = CollectionViewSource.GetDefaultView(data); } XAML data binding:
<DataGrid x:Name="DataGridProducts" AutoGenerateColumns="True" IsSynchronizedWithCurrentItem="False" ItemsSource="{Binding Item}" SelectedItem="{Binding SelectedItem}"> </DataGrid> I need to get the selected row from the DataGrid , but I don't know how to do it.
Data for the DataGrid subject to change (different requests - different DataTable ).
GetType()what does it say? - Andrey NOP