tags:

views:

12

answers:

1

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

DataGridColumnHeader 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?

+1  A: 

Just use the Column property:

public DataGridColumn SomeCoolMethod(DataGridColumnHeader header)
{
    return header.Column;
}
Quartermeister
Whoosh, now that one just sneaked by me - I did not notice that it has such a property! Thanks a lot!
Jefim