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.
Unfortunately, activation email could not send to your email. Please try again.

HeaderToolTipTemplate with HeaderText instead of MappingName

Thread ID:

Created:

Updated:

Platform:

Replies:

130900 Jun 9,2017 04:41 AM Jun 12,2017 11:53 PM WPF 2
loading
Tags: SfDataGrid
Victor Dienstbier
Asked On June 9, 2017 04:41 AM

Hi!

I'm trying to define a DataTemplate for the HeaderToolTip in a SfDataGrid. After setting the ShowHeaderToolTip to true it displays the MappingName ("OrderID"). Now I'd like to show the HeaderText ("Order Number") and some other information instead. For example like this:


I tried to create a DataTemplate like this but it only shows an empty Box:

<DataTemplate x:Key="TemplateDataGridHeaderToolTip">
            <TextBlock Text="{Binding RelativeSource={RelativeSource Self}, Path=HeaderText}" />
</DataTemplate>

Now I'm creating the columns in Code Behind and add the template like this:

newColumn.ShowHeaderToolTip = true;
DataTemplate templateDataGridHeaderToolTip = (DataTemplate)TryFindResource("TemplateDataGridHeaderToolTip");
if (templateDataGridHeaderToolTip != null) { newColumn.HeaderToolTipTemplate = templateDataGridHeaderToolTip; }

Is there anything I'm missing or doing wrong?

Thank you very much for your help!


Victor

Muthukumar Kalyanasundaram [Syncfusion]
Replied On June 12, 2017 11:44 PM

Hi Victor, 
 
Thank you for contacting Syncfusion support. 
 
We have analyzed your code.  The HeaderTooltip header text shows as empty because while setting RelativeSource as Self will bind the same control as a source for current binding. Hence, it will search for the path “HeaderText” given in the current binding, inside the textblock, there is no property named as “HeaderText”, so it will return null value will be displayed. For your reference, we have attached the link in below.  


You can re-solve this problem by binding the HeaderText as shown like below code snippet: 

Code Snippet: Xaml 
 
 
<Window.Resources>        
    <DataTemplate x:Key="TemplateDataGridHeaderToolTip"> 
        <Grid> 
            <Grid.ColumnDefinitions> 
                <ColumnDefinition Width="40"/> 
                <ColumnDefinition Width="*"/> 
            </Grid.ColumnDefinitions> 
            <Image Source="User.png"  Grid.Column="0" Height="20"/> 
            <TextBlock Text="{Binding Path=HeaderText}" Grid.Column="1" /> 
        </Grid> 
    </DataTemplate> 
</Window.Resources> 



Please let us know if you have any query. 

Regards, 
Muthukumar K 


Muthukumar Kalyanasundaram [Syncfusion]
Replied On June 12, 2017 11:53 PM

Hi Victor, 
 
Thank you for contacting Syncfusion support. 
 
We have analyzed your code.  The HeaderTooltip header text shows as empty because while setting RelativeSource as Self will bind the same control as a source for current binding. Hence, it will search for the path “HeaderText” given in the current binding, inside the textblock, there is no property named as “HeaderText”, so it will return null value will be displayed. For your reference, we have attached the link in below.  


You can re-solve this problem by binding the HeaderText as shown like below code snippet: 

Code Snippet: Xaml 
 
 
<Window.Resources>        
    <DataTemplate x:Key="TemplateDataGridHeaderToolTip"> 
        <Grid> 
            <Grid.ColumnDefinitions> 
                <ColumnDefinition Width="40"/> 
                <ColumnDefinition Width="*"/> 
            </Grid.ColumnDefinitions> 
            <Image Source="User.png"  Grid.Column="0" Height="20"/> 
            <TextBlock Text="{Binding Path=HeaderText}" Grid.Column="1" /> 
        </Grid> 
    </DataTemplate> 
</Window.Resources> 



Please let us know if you have any query. 

Regards, 
Muthukumar K 


CONFIRMATION

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.

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.

;