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

Datagrid Header Text Binding Issues

1 Answer 724 Views
DataGrid
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Muralidharan
Top achievements
Rank 1
Muralidharan asked on 01 Sep 2016, 09:56 AM

On trying to Bind the Header Text for the Datagrid columns fails to bind, 

telerikGrid:DataGridDateColumn Header="{Binding DateHeader}" x:Name="colGridDate" PropertyName="TestDateTime" gets filled with the property name instead of the DateHeader in the View Model.

While defining the header as

<telerikGrid:DataGridDateColumn.Header>
                            <TextBlock Text="{Binding DateHeader}">
                            </TextBlock>
                        </telerikGrid:DataGridDateColumn.Header>

also doesnt bind the value, whereas on Harding the Text. It displays it in the UI.(TextBlock Text="Date").

Kindly help me in binding the value from my view model.

Thanks,

1 Answer, 1 is accepted

Sort by
0
Patrick | Technical Support Engineer, Senior
Telerik team
answered on 01 Sep 2016, 06:50 PM
Hello Muralidharan,

The DataContext of the Header is the column itself (in your case, its a DataGridDateColumn), so you need to set your binding to point towards the view model. For example, use an ElementName binding or x:Bind (e.g. Text="{Binding DataContext.DateHeader, ElementName=MyPage}" ). 

I've attached a project which illustrates the DataContext of the TextBlock.

I hope this clears things.

Regards,
Patrick
Telerik by Progress
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 Feedback Portal and vote to affect the priority of the items
Tags
DataGrid
Asked by
Muralidharan
Top achievements
Rank 1
Answers by
Patrick | Technical Support Engineer, Senior
Telerik team
Share this question
or