Marco
Marco

Reputation: 563

Access GridViewColumnHeader object from GridViewColumn

is it possible in wpf to access the header of a gridviewcolumn as gridviewcolumnheader?

I have an object:

GridViewColumn column;

But the "Header" property just returns a string (header text) not the "real" header object.

Can anyone help my?

Upvotes: 8

Views: 3143

Answers (2)

elshev
elshev

Reputation: 1573

I've summarized different ways to find GridViewColumnHeader from GridViewColumn here: http://apaers.com/wpf-listview-access-gridviewcolumnheader-from-gridviewcolumn/

Upvotes: 2

Brendan Grant
Brendan Grant

Reputation: 1022

I am myself very inexperianced with WPF... however it appears that that if you you do not define a GridViewColumnHeader, then you will not be given one when accessing .Header.

That is to say, if you define your GridViewColumn as:

                <GridViewColumn x:Name="stringColumn">
                    stringColumn.Header will return a string
                </GridViewColumn>

Then calling stringColumn.Header will return a string... however if you define it as say:

                <GridViewColumn x:Name="gridViewColumnHeaderColumn1">
                    <GridViewColumnHeader>
                        gridViewColumnHeaderColumn.Header will return a GridViewColumnHeaderColumn
                    </GridViewColumnHeader>
                </GridViewColumn>

Then checking gridViewColumnHeaderColumn.Header will return a GridViewColumnHeaderColumn

Upvotes: 3

Related Questions