Change font color, font size etc. of the interval headings

2 Answers 34 Views
TimeLine
Gerhard
Top achievements
Rank 1
Iron
Iron
Gerhard asked on 04 Feb 2025, 08:54 AM

Hello, I am using the WPF-RadTimeLine control and would like to change the color and font size of the interval headings.

Hello, I am using the WPF-RadTimeLine control and would like to change the color and font size of the interval headings.

What is the procedure here?

2 Answers, 1 is accepted

Sort by
0
Stenly
Telerik team
answered on 06 Feb 2025, 03:11 PM

Hello Gerhard,

For the grouping part of the question, to achieve this requirement, add a new Style in the Resources collection of RadTimeline that targets the TimelineGroupPeriodControl element and set its FontSize and Foreground properties:

<telerik:RadTimeline.Resources>
    <Style TargetType="telerik:TimelineGroupPeriodControl">
        <Setter Property="FontSize" Value="18" />
        <Setter Property="Foreground" Value="Red"/>
    </Style>
</telerik:RadTimeline.Resources>

For the hours part of the question, add a new Style that targets the TimelinePeriodControl and sets the same properties as in the above code snippet:

<telerik:RadTimeline.Resources>
    <Style TargetType="telerik:TimelineGroupPeriodControl">
        <Setter Property="FontSize" Value="18" />
        <Setter Property="Foreground" Value="Red"/>
    </Style>
    <Style TargetType="telerik:TimelinePeriodControl">
        <Setter Property="FontSize" Value="12"/>
        <Setter Property="Foreground" Value="Orange"/>
    </Style>
</telerik:RadTimeline.Resources>

The produced result is as follows:

With this being said, I hope the provided information will be of help to you.

Regards,
Stenly
Progress Telerik

Love the Telerik and Kendo UI products and believe more people should try them? Invite a fellow developer to become a Progress customer and each of you can get a $50 Amazon gift voucher.

Gerhard
Top achievements
Rank 1
Iron
Iron
commented on 18 Feb 2025, 07:40 AM

Thank you for the information. I have implemented your suggestion.
But it only worked for me after I used BasedOn for the styles. (BasedOn=“{StaticResource TimelineGroupPeriodControlStyle}” or BasedOn=“{StaticResource TimelinePeriodControlStyle}”).
I have adjusted the height according to the documentation. (https://docs.telerik.com/devtools/wpf/controls/radtimeline/how-to/howto-change-size-periodheader).
Unfortunately, the annotations and the TimeLineItems are now not moved down.

Is there a solution for this?

Translated with DeepL.com (free version)

0
Gerhard
Top achievements
Rank 1
Iron
Iron
answered on 18 Feb 2025, 07:40 AM

Hello Stenly,

 

Thank you for the information. I have implemented your suggestion.
But it only worked for me after I used BasedOn for the styles. (BasedOn=“{StaticResource TimelineGroupPeriodControlStyle}” or BasedOn=“{StaticResource TimelinePeriodControlStyle}”).
I have adjusted the height according to the documentation. (https://docs.telerik.com/devtools/wpf/controls/radtimeline/how-to/howto-change-size-periodheader).
Unfortunately, the annotations and the TimeLineItems are now not moved down.

Is there a solution for this?

Translated with DeepL.com (free version)

Stenly
Telerik team
commented on 18 Feb 2025, 01:40 PM

I tried reproducing this behavior by following the approach from the article that you provided, however, I was unsuccessful. On my end, the following result is present:

I attached the sample project that I used for testing, so, would it be possible to give it a try?

Gerhard
Top achievements
Rank 1
Iron
Iron
commented on 19 Feb 2025, 02:37 PM

Thank you for the test project. This works for me exactly as described. However, if I set the font size of 'TimelineGroupPeriodControl' even larger, the font is cut off. I wanted to prevent this and have inserted the following:
<telerik:RadTimeline.GroupPeriodHeaderStyle>
     <Style TargetType=“Border”>
         <Setter Property=“Height” Value=“36” />
     </Style>
 </telerik:RadTimeline.GroupPeriodHeaderStyle>

This makes the field inc. font larger but causes the described shift. If I define a height in the 'TimelineGroupPeriodControl', the font is still cut off.
Stenly
Telerik team
commented on 24 Feb 2025, 10:51 AM

Hello Gerhard,

To prevent this behavior from appearing, you could keep the custom Style for the GroupPeriodHeaderStyle property and specify values for the Margin property of the TimeLineItemGroupsPanel instance for the ItemsPanel property of the TimelineItemContainer.

The following code snippet shows what I have in mind:

<!--Your custom Style-->
<telerik:RadTimeline.GroupPeriodHeaderStyle>
    <Style TargetType="Border">
        <Setter Property="Height" Value="36" />
    </Style>
</telerik:RadTimeline.GroupPeriodHeaderStyle>
<telerik:RadTimeline.Resources>
    <Style TargetType="telerik:TimelineGroupPeriodControl">
        <!--Increased font size-->
        <Setter Property="FontSize" Value="28" />
        <Setter Property="Foreground" Value="Red"/>
    </Style>
    <Style TargetType="telerik:TimelinePeriodControl">
        <Setter Property="FontSize" Value="12"/>
        <Setter Property="Foreground" Value="Orange"/>
    </Style>
    <Style TargetType="telerik:TimelineItemContainer" >
        <Setter Property="ItemsPanel">
            <Setter.Value>
                <ItemsPanelTemplate>
                    <!--Specified Margin-->
                    <telerik:TimelineItemGroupsPanel Margin="0 15 0 0" Padding="0 70 0 5" />
                </ItemsPanelTemplate>
            </Setter.Value>
        </Setter>
    </Style>
</telerik:RadTimeline.Resources>

The produced result is as follows:

With this being said, could you give this suggestion a try?

Gerhard
Top achievements
Rank 1
Iron
Iron
commented on 25 Feb 2025, 03:28 PM

Hi, thank you.
Works great!
Stenly
Telerik team
commented on 26 Feb 2025, 09:20 AM

I am happy to hear it. Please let me know if any additional assistance about this scenario is required.
Tags
TimeLine
Asked by
Gerhard
Top achievements
Rank 1
Iron
Iron
Answers by
Stenly
Telerik team
Gerhard
Top achievements
Rank 1
Iron
Iron
Share this question
or