GroupPath converter function ?

5 posts, 1 answers
  1. Jean Ressouche
    Jean Ressouche avatar
    81 posts
    Member since:
    Aug 2012

    Posted 17 Aug 2012 Link to this post

    Hi, i'm evaluating the possibility to use the timeline component on our app, but the group capability seems a little bit poor (indeed, unlike the gantview for comparaison). is there a way to display in the group part something else than the value used for grouping ?
    I would like to group using a int ID, but to display a string (or a more complete usercontrol!). Seems logic to me to ducplicate as group only an id instead of the wanted display string.

    Any idea ? Template hack ?

    Cordially,
    Jean
  2. Answer
    Tsvetie
    Admin
    Tsvetie avatar
    1517 posts

    Posted 23 Aug 2012 Link to this post

    Hi Jean,

    You can use the style of the TimelineItemGroupControl type to achieve this result. For example, in case you just want to change the display string, you can specify it using the Header property and a converter:

    <Style TargetType="timelines:TimelineItemGroupControl" BasedOn="{StaticResource TimelineItemGroupControlStyle}">
        <Setter Property="Header" Value="{Binding DataItems, Converter={StaticResource headerTextConverter}}" />
    </Style>

    You can extract the business object from the first item in DataItems in the converter the following way:
    MyBusinessType dataItem = this.DataItems.First().DataItem as MyBusinessType;

    In case you want to change the header template, you can customize it using the HeaderTemplate property. For example:
    <Style TargetType="timelines:TimelineItemGroupControl" BasedOn="{StaticResource TimelineItemGroupControlStyle}">
        <Setter Property="HeaderTemplate">
            <Setter.Value>
                <DataTemplate>
                    <Grid Margin="0,5,0,0">
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="Auto" />
                            <ColumnDefinition Width="*" />
                        </Grid.ColumnDefinitions>
                        <TextBlock Grid.Column="0" Text="{Binding}" Margin="4 0 0 0" HorizontalAlignment="{Binding Path=HorizontalContentAlignment, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type timelines:TimelineItemGroupControl}}}"></TextBlock>
                        <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>
                </DataTemplate>
            </Setter.Value>
        </Setter>
        <Setter Property="Header" Value="{Binding DataItems, Converter={StaticResource headerTextConverter}}" />
    </Style>

    For additional information on customizing the Styles of out controls, please refer to the following help topic - http://www.telerik.com/help/silverlight/styling-apperance-implicit-styles-overview.html.

    Kind regards,
    Tsvetie
    the Telerik team

    Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

  3. DevCraft banner
  4. Jean Ressouche
    Jean Ressouche avatar
    81 posts
    Member since:
    Aug 2012

    Posted 23 Aug 2012 Link to this post

    Seems perfect, thanks !
  5. Josh Eastburn
    Josh Eastburn avatar
    32 posts
    Member since:
    Aug 2012

    Posted 20 Dec 2012 Link to this post

    Has something changed with the TimelineItemGroupControl in the latest version of the RadTimeline?

    I am using a custom version of Telerik.Windows.Controls.DataVisualization.xaml and I know my configuration is working because I was able to add a custom vertical ScrollViewer on the timeline in this same file.

    But any changes I try to make in the TimelineItemGroupControl similar to those posted above have no effect.  I have tried making changes to the included style, and even a hard-coded Header value has no effect:

    <Style TargetType="timelines:TimelineItemGroupControl" BasedOn="{StaticResource TimelineItemGroupControlStyle}">
        <Setter Property="Header" Value="This doesn't work!"></Setter>
    </Style>


    Thanks,
    Josh
  6. Tsvetie
    Admin
    Tsvetie avatar
    1517 posts

    Posted 21 Dec 2012 Link to this post

    Hello Josh,

    Yes, you are correct - you cannot use the XAML solution that I posted before with Q3 2012. This is a result of a bugfix. I will log the problem that you have run into.

    For the time being, you can use the same approach with the converter in the Template of the TimelineItemGroupControlStyle - simply change all TemplateBindings to the Header property with the new Binding expressing with converter.

    All the best,
    Tsvetie
    the Telerik team

    Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

Back to Top
DevCraft banner