We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Bind the Custom HeaderTemplate name to the MappingName

Thread ID:





140876 Nov 12,2018 07:00 PM UTC Nov 13,2018 09:58 AM UTC Xamarin.Forms 1
Tags: SfDataGrid
Mark Tannehill
Asked On November 12, 2018 07:00 PM UTC

I want to customize my headers to be different colors on my SfDataGrid. The trouble is, that I have to update my header names based on some other inputs on my tool.

I am able to get the HeaderTemplate to update to my correct initial settings but cannot seem to update the value easily.

What I'm hoping is that I can bind my internal label text to the MappingName, might look something like this in XAML, but I'm looking for the C# version. 

    <syncfusion:GridTextColumn MappingName="OrderID">
                <Label x:Name="OrderID" Text="{Binding MappingName}" TextColor="Black" />
</syncfusion:SfDataGrid.Columns> Here is kinda what I'm looking for... 

  private static DataTemplate HeaderTemplate(Color color) {
            return new DataTemplate(() => {
                var label = new Label() { Text = (#WHAT GOES HERE?#), BackgroundColor = color };
                return new ViewCell { View = label };

Suhasini  Suresh [Syncfusion]
Replied On November 13, 2018 09:58 AM UTC

Hi Mark, 
Thanks for contacting Syncfusion Support. 
We checked your query, please find the below code snippet to achieve your requirement to set the binding for the TextProperty in code behind. 
private static DataTemplate HeaderTemplate(Color color) 
    return new DataTemplate(() => { 
        var label = new Label() 
            BackgroundColor = color 
        label.SetBinding(Label.TextProperty, "MappingName"); 
        return new ViewCell { View = label }; 


This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

Live Chat Icon For mobile
Live Chat Icon