开发者

WPF - Get DataGridColumn from its DataGridColumnHeader

开发者 https://www.devze.com 2023-01-11 17:03 出处:网络
I need to get the exact DataGridColumn that is associated with the DataGridColumnHeader. So, basically: fill in the gaps in the following code: :)

I need to get the exact DataGridColumn that is associated with the DataGridColumnHeader. So, basically: fill in the gaps in the following code: :)

DataGridColumnHea开发者_如何转开发der myHeader; // this is a given value
DataGridColumn myColumn = SomeCoolMethod(myHeader);

public DataGridColumn SomeCoolMethod(DataGridColumnHeader header)
{
    // ???
}

Ok, some more text - I can travel up the visual tree but it seems, that the real headers are contained in a separate branch or something. I get to my DataGrid visual without encountering any DataGridColumns. I am not sure where to search for the initial column and then - how do I find this specific column that caused the header?


Just use the Column property:

public DataGridColumn SomeCoolMethod(DataGridColumnHeader header)
{
    return header.Column;
}
0

精彩评论

暂无评论...
验证码 换一张
取 消