SfDataGrid: how to bind the header of a column to a ViewModel?
Hi Andreas,
Thanks for contacting syncfusion support.
We have analyzed your query.You can achieve the requirement by setting ViewModel as source value for the binding. We have created a simple sample to achieve this requirement and please check the sample under the following location,
Sample: http://www.syncfusion.com/downloads/Support/DirectTrac/110157/Headerbinding-1493656320.zip
Please let us know if you need further assistance.
Thank you,
Jai Ganesh S
In my situation I need to bind the heading text to a property on the data templates data context, the view model cannot be instantiated within XAML and the heading text value needs to change as the view model property is updated.
Hi Jason,
You can achieve your requirement by using ElementName Binding as shown in the following code snippet.
|
<syncfusion:SfDataGrid.Columns> <syncfusion:GridTextColumn MappingName="EmployeeId" HeaderText="{Binding ElementName=datagrid, Path=DataContext.CustomHeaderText, Mode=TwoWay}"/> </syncfusion:SfDataGrid.Columns> |
We have created a sample to achieve this requirement and please check the following sample link.
http://www.syncfusion.com/uploads/user/directTrac/120528/Headerbinding-1069340575.zip
Please let us know if you require further assistance
Thanks,
Ashok
- 4 Replies
- 4 Participants
-
AM Andreas Myka
- Jul 8, 2013 01:07 PM UTC
- Mar 19, 2014 10:43 AM UTC