My problem is that I have datagrid filled in code like :
(...)
while (rdr.Read())
{
dataGrid1.Items.Add(new Produkt { nazwa = rdr.GetString(rdr.GetOrdinal("nazwa")), cena = rdr.GetString(rdr.GetOrdinal("cena")), kod = rdr.GetString(rdr.GetOrdinal("kod")) });
}
(...)
but before i’v declared all columns in my datagrid:
DataGridTextColumn col1 = new DataGridTextColumn();
DataGridTextColumn col2 = new DataGridTextColumn();
DataGridTextColumn col3 = new DataGridTextColumn();
dataGrid1.Columns.Add(col1);
dataGrid1.Columns.Add(col2);
dataGrid1.Columns.Add(col3);
col1.Binding = new Binding("nazwa");
col2.Binding = new Binding("cena");
col3.Binding = new Binding("kod");
col1.Header = "nazwa";
col2.Header = "cena";
col3.Header = "kod";
Now i have added filtering by entered text, so i have 3 textBoxes under datagrid (each column) but their width is not like width from columns in datagrid. I have tried somethink like textbox1.width = datagrid.columns[1].width, but that doesnt work.
Anyone know solution for my problem?
Thanks for any answers!
ps. i cannot just like that declare width (f.e. textbox.width = 200)
Try something like that:
XAML file:
Code-behind file:
MainViewModel: