Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
ListView要在 WPF 中获取 a 列,我们可以这样做
ListView
((GridView) someListView.View).Columns[index]
但是如何获得一个GridViewColumn只知道其标题的名称?
GridViewColumn
你应该试试这个: ((GridView) _lvContacts.View).Columns.FirstOrDefault(x => (string) x.Header == "Name"); 当然,你必须确保列的标题只是一个字符串(就像在你的示例代码中一样)。
((GridView) _lvContacts.View).Columns.FirstOrDefault(x => (string) x.Header == "Name");