6

In WPF Datagrid, i am adding Column dynamically for that i want to set X:Name property of DataGrid column by C#

My Code:

DataGridTextColumn clm = new DataGridTextColumn();
                    clm.Header = "Marks";
                    clm.Width = 100;
                    clm.IsReadOnly = false;
                    dgChapters.Columns.Add(clm);

How to set X:Name property on DataGridTextColumn by C#

Avinash Singh
  • 2,697
  • 11
  • 44
  • 72

1 Answers1

4
//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;
Yii
  • 56
  • 2