simona a

simona a

  • NA
  • 5
  • 0

Binding Datatable to a datagrid in WPF

May 25 2015 7:48 PM

I have a view model in my C# 4.0 app which has a System.Data.DataTable that's created in it using a service call. I want to bind this to a datagrid in my XAML file.

I tried following line DataGrid_Loaded event but its getting fired up before my datatable gets created inside the view model.

xaml:

<dg:DataGrid Name="myDataGrid" Loaded="DataGrid_Loaded"/>

xaml.cs:

myDataGrid.ItemsSource = myViewModel.myDataTable.DefaultView;
 
Thanks. 

Answers (1)