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

Grouping by Object and custom group header

2 Answers 189 Views
TimeLine
This is a migrated thread and some comments may be shown as answers.
Massimo
Top achievements
Rank 1
Massimo asked on 21 Oct 2014, 01:23 PM
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 Answers, 1 is accepted

Sort by
0
Massimo
Top achievements
Rank 1
answered on 21 Oct 2014, 01:56 PM
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>
0
Martin Ivanov
Telerik team
answered on 24 Oct 2014, 12:58 PM
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.

 
Tags
TimeLine
Asked by
Massimo
Top achievements
Rank 1
Answers by
Massimo
Top achievements
Rank 1
Martin Ivanov
Telerik team
Share this question
or