Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to set the X:Name property through C# in wpf datagrid column

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#

like image 863
Avinash Singh Avatar asked Oct 22 '22 04:10

Avinash Singh


1 Answers

//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;
like image 153
Yii Avatar answered Nov 01 '22 14:11

Yii