Grouping by Object and custom group header

3 posts, 0 answers
  1. Massimo
    Massimo avatar
    21 posts
    Member since:
    Apr 2013

    Posted 21 Oct 2014 Link to this post

    Hi, I'm grouping my list of values from an object. 
    This object might be one of these 3 classes: Class1, Calss2, Calss3. This is working.

    I followed your sample: http://www.telerik.com/forums/group-header-style for a custom header template.

    But when I'm selecting the template from each group header I find the string "Class1", "Calss2", "Calss3" instead of its real value.

    What am I doing wrong? Am I missing something?
  2. Massimo
    Massimo avatar
    21 posts
    Member since:
    Apr 2013

    Posted 21 Oct 2014 in reply to Massimo Link to this post

    Ok, it might be rude, but it's working so far:

    <Style x:Key="TimelineItemGroupControlStyle1" TargetType="timelines:TimelineItemGroupControl" BasedOn="{StaticResource TimelineItemGroupControlStyle}">
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="timelines:TimelineItemGroupControl">
                    <Border Background="{TemplateBinding Background}"
                        BorderBrush="{TemplateBinding BorderBrush}"
                        BorderThickness="{TemplateBinding BorderThickness}">
                        <Grid>
                            <Grid.RowDefinitions>
                                <RowDefinition Height="Auto" />
                                <RowDefinition Height="*" />
                            </Grid.RowDefinitions>
     
                            <Grid x:Name="Header" Grid.Row="0" Margin="0 5 0 0"
                                            Visibility="{Binding Path=HasHeader, RelativeSource={RelativeSource TemplatedParent}, Converter={StaticResource booleanToVisibilityConverter}}">
                                <Grid.ColumnDefinitions>
                                    <ColumnDefinition Width="Auto" />
                                    <ColumnDefinition Width="*" />
                                </Grid.ColumnDefinitions>
     
                                <ContentControl Grid.Column="0"
                                                Content="{Binding DataGroups[0].DataItems[0].Group}"
                                                ContentTemplate="{TemplateBinding HeaderTemplate}"
                                                ContentTemplateSelector="{StaticResource headerTemplateSelector}">
                                </ContentControl>
                                 
                                <Path Grid.Column="1"
                                                    VerticalAlignment="Center"
                                                    HorizontalAlignment="Stretch"
                                                    Data="M0,0 L800,0"
                                                    Height="{StaticResource Timeline_TimelineItemGroup_Separator_Height}"
                                                    Margin="5 1 0 0"
                                                    Stretch="Fill"
                                                    Stroke="{StaticResource Timeline_TimelineItemGroup_Separator_Stroke}" />
                            </Grid>
                            <ItemsPresenter x:Name="Content" Grid.Row="1" />
                        </Grid>
                    </Border>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>
     
    <Style TargetType="timelines:TimelineItemGroupControl" BasedOn="{StaticResource TimelineItemGroupControlStyle1}">
        <Setter Property="IsExpanded" Value="True" />
    </Style>
  3. UI for WPF is Visual Studio 2017 Ready
  4. Martin
    Admin
    Martin avatar
    1099 posts

    Posted 24 Oct 2014 Link to this post

    Hello Massimo,

    I am glad to hear that you achieved your requirement.

    Note that whatever object you pass as a Header of the timeline groups through the RadTimeline's GroupPath property, the returned value from the object's ToString() value will be used as a value of the Header property. 

    The approach you are currently using is fine for your requirement. Another approach could be to override the ToString() method of your objects and return a proper value.

    Regards,
    Martin
    Telerik
     

    Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

     
Back to Top