Avi*_*ngh 5 c# wpfdatagrid wpf-4.0
在 WPF Datagrid 中,我正在动态添加 Column,因为我想通过 C# 设置 DataGrid 列的 X:Name 属性
我的代码:
DataGridTextColumn clm = new DataGridTextColumn();
clm.Header = "Marks";
clm.Width = 100;
clm.IsReadOnly = false;
dgChapters.Columns.Add(clm);
Run Code Online (Sandbox Code Playgroud)
如何通过 C# 在 DataGridTextColumn 上设置 X:Name 属性
小智 5
//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;
Run Code Online (Sandbox Code Playgroud)