i’m moving from windows form to wpf but now i have a problem.
i get info from database(sql server) and store that in a dataset and i want to show that in a datagrid (dg)
DataSet ds = new DataSet();
SqlConnection sc = new SqlConnection("mysqlconnection");
SqlDataAdapter sd = new SqlDataAdapter();
sc.Open();
sd.SelectCommand = new SqlCommand("SELECT * FROM table_1", sc);
sd.Fill(ds);
dg.DataContext = ds.Tables[0].DefaultView;//here is the problem
sc.Close();
in windows forms it was dg.DataSrouce but i can’t find that in wpf, any help ?
Either add
ItemsSource="{Binding}"to yourDataGriddefinition or changeto
Update
Try to add
AutoGenerateColumns="True"