foreach (DataGridColumn col in PEDQueryNewDataGrid.Columns) { if (col.Header.ToString().ToLower() == "code") { gridUnmapped.Columns.Remove(col); break; } }
string bindName = "Attributes[S_" + InputPED.Text + "]"; DataGridTextColumn colPED = new DataGridTextColumn(); colPED.Header = "Code"; colPED.CanUserSort = true; colPED.Width = new DataGridLength(50); colPED.Binding = new System.Windows.Data.Binding(bindName); PEDQueryNewDataGrid.Columns.Add(colPED);
I could be wrong but I think the binding is interpreted literally in the XAML, so it's looking for an attribute name 'S_ + InputPED.Text' in your underlying data.Maybe in the Loaded event for the datagrid you can do something like this - In the XAML remove the column from the gridin the code behind string bindName = "Attributes[S_" + InputPED.Text + "]"; DataGridTextColumn colPED = new DataGridTextColumn(); colPED.Header = "Code"; colPED.CanUserSort = true; colPED.Width = new DataGridLength(50); colPED.Binding = new Binding(bindName); // assuming the datagrid is called gridData - replace with the name of your datagrid gridData.Columns.Add(colPED);
string bindName = "Attributes[S_" + InputPED.Text + "]"; DataGridTextColumn colPED = new DataGridTextColumn(); colPED.Header = "Code"; colPED.CanUserSort = true; colPED.Width = new DataGridLength(50); colPED.Binding = new Binding(bindName); // assuming the datagrid is called gridData - replace with the name of your datagrid gridData.Columns.Add(colPED);
Angemeldete Mitglieder können Beiträge verfassen, Updates folgen und mehr. Neu hier? Registriere ein kostenloses Konto.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.