GroupHeaderTemplate does not support RelativeSource={RelativeSource AncestorType=telerik:RadGridView}}"

3 posts, 0 answers
  1. Bryce
    Bryce avatar
    32 posts
    Member since:
    Aug 2010

    Posted 17 Jul 2012 Link to this post


    I have a group header template and I want to find the ID of the the parent data context. In SL5, you can do this:

    <TextBlock Text="{Binding DataContext.ID, RelativeSource={RelativeSource AncestorType=telerik:RadGridView}}"/>
    When I put this as a celltemplate in the column in the grid, it is able to get the ID, however when it is put in the groupheadertemplate, it does not get the ID.

    I know the it is being bound to is the GroupViewModel, but its namespace is: Telerik.Windows.Controls.GridView so you would think you would be able to get the ID of the DataContext the RadGridView is within.
    Any one know a way around this?


  2. Dimitrina
    Dimitrina avatar
    3769 posts

    Posted 18 Jul 2012 Link to this post

    Hello Bryce,

    I would suggest you to expose the DataContext as a StaticResource. Then use it for the Binding, for example:
    <TextBlock Text="{Binding ID, Source={StaticResource MyDataContext}}"/> 

    the Telerik team

    Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

  3. Fredy
    Fredy avatar
    7 posts
    Member since:
    Mar 2012

    Posted 24 Nov 2012 Link to this post

    Hi, How can show the name of month in the GroupHeaderTemplate?

    I tried this:

    <telerik:GridViewDataColumn DataMemberBinding="{Binding Date, StringFormat='MMM dd yyyy, ddd'}">
                                            Caption="Days: "/>
                                    <telerik:GridViewDataColumn DataMemberBinding="{Binding Month}" IsVisible="False">
                                                <StackPanel Orientation="Horizontal">
                                                    <TextBlock Text="{Binding Date, StringFormat='MMMM'}" />

                                    <telerik:GroupDescriptor Member="Year" SortDirection="Descending"/>
                                    <telerik:GroupDescriptor Member="Month" SortDirection="Descending"/>

    Tks!!! :)

Back to Top