Articles in this section
Category / Section

How to bind a property of the ViewModel in the HeaderTemplate?

1 min read

SfDataGrid allows you to load HeaderTemplate for a GridColumn to load a customized view of choice. You can bind a property in the ViewModel to a view inside the HeaderTemplate and set its BindingContext to be the reference of ViewModel to get it working.

Refer the below code example in which a property in ViewModel is bind to the Label and its BindingContext is set as ViewModel.

  <sfgrid:GridTextColumn MappingName="OrderID">
        <Label BindingContext="{StaticResource viewModel}" 
             Text="{Binding HeaderText}"


On executing the above code, the below output will be obtained.



Sample Link:

How to bind a property of the ViewModel in the HeaderTemplate

Did you find this information helpful?
Help us improve this page
Please provide feedback or comments
Comments (0)
Please sign in to leave a comment