This is a migrated thread and some comments may be shown as answers.

Binding the Header property of a GridViewColumn

2 Answers 361 Views
GridView
This is a migrated thread and some comments may be shown as answers.
project30
Top achievements
Rank 1
project30 asked on 26 May 2010, 03:39 AM
Hi,

I need to do something like the following :
            <r:GridViewColumn Header="{Binding Path=Whatever}">
                <r:GridViewColumn.CellTemplate>
                    <DataTemplate>
                        <TextBlock Text="{Binding TotalUnits}" />
                    </DataTemplate>
                </r:GridViewColumn.CellTemplate>
            </r:GridViewColumn>

It doesn't work.  There's no binding error displayed to the Output Window (normally, all binding errors are displayed there).  The header is just plain empty in my grid.  Before you tell me that the property may not exist, I must add that I also tried {Binding .} (or {Binding Path=.} if you prefer); at least, it should display the ToString value of the current DataContext, whatever it is, but again, nothing is displayed.

Thanks in advance

2 Answers, 1 is accepted

Sort by
0
Maya
Telerik team
answered on 27 May 2010, 08:24 AM
Hello invertedRider,

Indeed you need a property created in order to bind the header to it. I am sending you a sample project that achieves the desired result.
However, if this does not meet exactly your requirements, please provide more details about your scenario and your expectations for the behavior of the application.
 

Greetings,
Maya
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
0
project30
Top achievements
Rank 1
answered on 27 May 2010, 02:56 PM
Maya,

Thanks for the reply!  But how come did I end up posting on the WPF thread??  My question related to Silverlight instead.  Sorry for that, and thanks again for replying.

Meanwhile, I learned that because the GridViewColumn isn't part of the visual tree, then you cannot use Binding, even though the Header property is a DependencyProperty.

Your example, though, thought me that this is not the case with WPF.  My hope is that the next release of Silverlight will fix it.

For now, my workaround is to manually do the binding using an attached property that I've crafted.
Tags
GridView
Asked by
project30
Top achievements
Rank 1
Answers by
Maya
Telerik team
project30
Top achievements
Rank 1
Share this question
or