Quantcast
Channel: Windows Presentation Foundation (WPF) forum
Viewing all articles
Browse latest Browse all 18858

Binding DataGrid to DataSet's DataTable

$
0
0

Im working on WPF using MVVM, and I need to bind a DataSet' tables to some DataGrids, but it is not working. My dataSet has 2 tables called "table01" and "table02".

In my XAML I have written the following:

<UserControl.DataContext>     <scr:MyViewModel/> </UserControl.DataContext>  <DataGrid Margin="0,0,0,0" Name="myGrid" ItemsSource="{Binding MyDataSet, Path=table01}" />

But no data is shown.

In my view model I have written the following:

private DataSet myDataSet; 
public DataSet MyDataSet     
{         
get         
{              
return myDataSet;           
}         
set         
{             
SetAndNotify(ref myDataSet, value, () => MyDataSet);        
 }     
}

Just to clarify, I fill my dataSet in the view model constructor, even I have printed the content of my dataSet and it has data and I have verified the connection to my DataContext and it is working normally. So, What I am doing wrong??

Hope someone can help me. Thank you in advance.


Viewing all articles
Browse latest Browse all 18858

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>