在WPF Datagrid中,我动态添加Column,我想通过C#设置DataGrid列的X:Name属性
我的代码:
DataGridTextColumn clm = new DataGridTextColumn();
clm.Header = "Marks";
clm.Width = 100;
clm.IsReadOnly = false;
dgChapters.Columns.Add(clm);
如何通过C#
在DataGridTextColumn上设置X:Name属性答案 0 :(得分:3)
//Registe it in a Method of a Window class
this.RegisterName("mark", clm);
//Use it in another Method like this
DataGridTextColumn clm2 = this.FindName("mark") as DataGridTextColumn;