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

GridViewColumn Header attribute databinding problem

2 Answers 57 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Brian
Top achievements
Rank 1
Brian asked on 14 May 2011, 09:26 PM

The Header attribute of my GridViewDataColumn is not binding.

<telerik:GridViewDataColumn Width="1.5*" UniqueName="DynamicColumn1" Header="{Binding DynamicColumn1Header}" DataMemberBinding="{Binding PositionName}" IsReadOnly="True"/>

I have also tried the following with no luck:

<telerik:GridViewDataColumn Width="1.5*" UniqueName="DynamicColumn1" DataMemberBinding="{Binding PositionName}" IsReadOnly="True">
    <telerik:GridViewDataColumn.Header>
        <TextBlock Text="{Binding DynamicColumn1Header}"/>
    </telerik:GridViewDataColumn.Header>
</telerik:GridViewDataColumn>

Please advise.  Thanks.

2 Answers, 1 is accepted

Sort by
0
Vlad
Telerik team
answered on 16 May 2011, 06:31 AM
Hi,

 With this binding you expect to have DynamicColumn1Header in the grid DataContext. Can you verify if this is the case? Where exactly this property is declared? 

Regards,
Vlad
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
Brian
Top achievements
Rank 1
answered on 16 May 2011, 07:43 PM

We are using typical MVVM.  The datacontext for the View (which contains the GridView) is set to the ViewModel which contains the property "DynamicColumn1Header".

private string _dynamicColumn1Header;        
 /// <summary>
/// DynamicColumn1 header display value (changes based on PositionType)
/// </summary>
public string DynamicColumn1Header
{
    get { return this._dynamicColumn1Header; }
    set
    {
        if (value != this._dynamicColumn1Header)
        {
            this._dynamicColumn1Header = value;
            this.RaisePropertyChanged("DynamicColumn1Header");
        }
    }
}

The setter is indeed being called and change notification occurs.  However, this value is not reflected in the Header.
Tags
GridView
Asked by
Brian
Top achievements
Rank 1
Answers by
Vlad
Telerik team
Brian
Top achievements
Rank 1
Share this question
or