How to get a GridViewColumn by its header's name in WPF?

1.8k views Asked by At

To get a column of a ListView in WPF we can do

((GridView) someListView.View).Columns[index] 

But how to get a GridViewColumn knowing only the name of its header?

1

There are 1 answers

0
MDoobie On BEST ANSWER

You should try this: ((GridView) _lvContacts.View).Columns.FirstOrDefault(x => (string) x.Header == "Name"); Of course, you have to be sure the column's header is only a string (just like in your sample code).