This is a migrated thread and some comments may be shown as answers.

HeaderCellStyle with ControlTemplate

4 Answers 283 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Thomas
Top achievements
Rank 1
Thomas asked on 28 Jul 2011, 10:00 AM
Hi,
I have some problems with the HeaderCellStyle. I want to show a TextBlock in the HeaderCell with the text coming from the GridViewDataColumn's Header property.

My style definition:
<UserControl.Resources>
  <Style TargetType="telerik:GridViewHeaderCell" x:Key="TextBlockStyle">
    <Setter Property="Template">
      <Setter.Value>
        <ControlTemplate TargetType="telerik:GridViewHeaderCell">
          <TextBlock Text="{Binding Path=.}"/>
        </ControlTemplate>
      </Setter.Value>
    </Setter>
  </Style>
</UserControl.Resources>

Usage of this style:
<telerik:GridViewDataColumn HeaderCellStyle="{StaticResource TextBlockStyle}" Header="HeaderText" DataMemberBinding="{Binding Path=BindingPath}"

I'm doing this, because I want to use the style on almost all my columns and to apply a tooltip to the TextBlock in code behind.

The problem is, that I don't know what to use as the binding in my ControlTemplate to show the header text.

regards Thomas

4 Answers, 1 is accepted

Sort by
0
Vanya Pavlova
Telerik team
answered on 28 Jul 2011, 10:30 AM
Hi Thomas,

 
Actually you do not have to predefine the template of GridViewheaderCell if you need to set a ToolTip. You may do this through assigning the ToolTipService property within a style:

<Grid.Resources>
        <Style x:Key="ss" TargetType="telerik:GridViewHeaderCell">
            <Setter Property="ToolTipService.ToolTip" Value="Header Cell Tooltip"/>
        </Style>
    </Grid.Resources>
    <Grid.RowDefinitions>
        <RowDefinition Height="Auto" />
        <RowDefinition Height="*" />
    </Grid.RowDefinitions>
    <TextBlock Grid.Row="0" HorizontalAlignment="Center" FontSize="22"  FontWeight="Bold"  Name="lbltile" Text="Sales House" VerticalAlignment="Top" />
    <StackPanel Orientation="Vertical" Grid.Row="1" >
        <telerik:RadGridView HorizontalAlignment="Center"  CanUserFreezeColumns="False" RowIndicatorVisibility="Collapsed"
                         IsFilteringAllowed="True" AutoGenerateColumns="False"  Name="RadGridView1" VerticalAlignment="Top">
            <telerik:RadGridView.Columns>
                <telerik:GridViewImageColumn HeaderCellStyle="{StaticResource ss}" DataMemberBinding="{Binding PathToImage}"/>
            </telerik:RadGridView.Columns>
        </telerik:RadGridView>
    </StackPanel>
     
</Grid>



If you need any further assistance let me know. 

Greetings,
Vanya Pavlova
the Telerik team

Register for the Q2 2011 What's New Webinar Week. Mark your calendar for the week starting July 18th and book your seat for a walk through of all the exciting stuff we will ship with the new release!

0
Thomas
Top achievements
Rank 1
answered on 28 Jul 2011, 10:48 AM
I know, but I don't know how to bind properties of the column to the tooltip text. It would be fine for me if I could get the column's UniqueName property in the HeaderCellStyle so that I could pass it into a Converter.

e.g.:
<Style x:Key="toolTipStyle" TargetType="telerik:GridViewHeaderCell">
            <Setter Property="ToolTipService.ToolTip" Value="{Binding Path=UniqueName"/>
</Style>
0
Accepted
Vanya Pavlova
Telerik team
answered on 28 Jul 2011, 01:33 PM
Hello Thomas,

 

For the time being Binding in Style setter cannot be achieved under Silverlight 4. However it will be possible in Silverlight 5. Another possible approach here outside of a style targeted at GridViewHeaderCell could be to define your custom header and set the tooltip from there:


<telerik:GridViewDataColumn DataMemberBinding="{Binding Name}" >
    <telerik:GridViewDataColumn.Header>
        <TextBlock Text="Name" ToolTip="Name tooltip" />
    </telerik:GridViewDataColumn.Header>
</telerik:GridViewDataColumn>

 
However you should implement some custom logic to display the ToolTip's content in the way you need. 

All the best,
Vanya Pavlova
the Telerik team

Register for the Q2 2011 What's New Webinar Week. Mark your calendar for the week starting July 18th and book your seat for a walk through of all the exciting stuff we will ship with the new release!

0
Thomas
Top achievements
Rank 1
answered on 28 Jul 2011, 01:44 PM
Thanks, I wasn't aware that it is not yet possible. Anyway thanks for taking your time.
Tags
GridView
Asked by
Thomas
Top achievements
Rank 1
Answers by
Vanya Pavlova
Telerik team
Thomas
Top achievements
Rank 1
Share this question
or