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. (Last updated on: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Can you databind headertext?

Thread ID:





91666 Nov 27,2009 01:39 AM UTC Jun 23,2015 12:19 PM UTC WPF 3
Tags: GridDataControl
Troy Johnson
Asked On November 27, 2009 01:39 AM UTC

I have a window in which the constructor sets the windows datacontext to an instance of a class called StockViewModel. The window has a syncfusion griddatacontrol with its its ItemsSource="{Binding Path=Stocks}" where Stocks is a property
on StockViewModel. If I create a GridDataVisibleColumn set the MappingName="StockId" a property on the Stock class, and the HeaderText="some string" everything works fine.

However what i need to do is set the HeaderText through binding in the xaml to a property on StockViewModel called StockIdHeader. I have tried a couple things using RelativeSource trying to get to the datacontext of the window but I can't get it to work.

I assume there is a way to do this because you can change the header text with the ShowColumnOptions dialog.

Here's my window, and the datacontext binding code from the windows codebehind.

Title="Test Syncfusion Grid"
Height="350" Width="525">

ItemsSource="{Binding Path=Stocks}">

HeaderText="{Binding StockIdHeader,
RelativeSource={RelativeSource FindAncestor,
AncestorType=Window}}" />

Window Codebehind window constructor:

public MainWindow()
StockViewModel _stockViewModel = new StockViewModel();
this.DataContext = _stockViewModel;

Ganesan K [Syncfusion]
Replied On November 30, 2009 06:53 AM UTC

Hi Troy,

Thanks for using Syncfusion products.

Right now it is not possible to databind a HeaderText property, since the GridDataVisibleColumn is just a DependencyObject, for DataBinding it requires to be a FrameworkElement.

Please let us know if you need any more details.


Francois Mongeau
Replied On June 22, 2015 10:08 PM UTC

Is it possible now, or will it Ever be?

Jayapradha S [Syncfusion]
Replied On June 23, 2015 12:19 PM UTC

Hi Troy Johnson,

Thank you for contacting Syncfusion support.

We analyzed your requirement and you can set the header text through binding from viewmodel as shown in the below code snippet:

Code Snippet:


private string headerText = "Column1";

        public string HeaderColumn


            get { return headerText; }

            set { headerText = value; }



        <local:ViewModel x:Key="viewModel"/>

  <syncfusion:GridDataVisibleColumn MappingName="OrderID"
                                    HeaderText="{Binding HeaderColumn, Source={StaticResource viewModel}}"/>

Please let us know if you require any further assistance on this.



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