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

Schedule View TimerulerMajorTickStringFormat

2 Answers 213 Views
ScheduleView
This is a migrated thread and some comments may be shown as answers.
Sebastiano
Top achievements
Rank 1
Sebastiano asked on 23 May 2011, 08:30 PM
Hi, 

I'm looking for a way to display week numbers in this field. Is it possible to do this in the current control version?

Thanks,
Sebastiano

2 Answers, 1 is accepted

Sort by
0
Konstantina
Telerik team
answered on 25 May 2011, 10:12 AM
Hello Sebastiano,

Unfortunately, displaying the week numbers in the TimeRuler is not possible, since they won't get update when the date range is changed. However, you can display them in the group headers of each view. Please find attache a sample project which illustrates this. The project is for Silverlight, however, the logic is the same. It contains also the full xaml of the ScheduleView, which will be of no use to you. Please verify that the templates used in MainPage.xaml are correct for WPF. For more information about customizing the Group Headers you can refer to this online demo.

Hope this helps. Please let us know if you have further questions.

All the best,
Konstantina
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Maxime
Top achievements
Rank 1
answered on 19 Aug 2016, 09:17 AM

I did some research on this issue and I kept finding this post over and over. Since I found a solution to display week in TimeRuler, I though it was a good idea to post it here.

You can display weeks on TimeRuler using the ITickProvider on MajorTickLength or MinorTickLength property of the ViewDefinition.

Here is a sample of the code I use for ITickProvider:

using System;
using Itenso.TimePeriod;
using Telerik.Windows.Controls.ScheduleView;
 
public class WeeklyTickProvider : ITickProvider
{
    public string GetFormatString(IFormatProvider formatInfo, string formatString, DateTime currentStart)
    {
        Week week = new Week(currentStart);
 
        return currentStart.Date == week.FirstDayOfWeek
            ? string.Format("W{0}", week.WeekOfYear)
            : string.Empty;
    }
 
    public DateTime GetNextStart(TimeSpan pixelLength, DateTime currentStart)
    {
        return new Week(currentStart).LastDayOfWeek.AddDays(1);
    }
}

Here is the xaml:

<t:RadScheduleView.ActiveViewDefinition>
    <t:TimelineViewDefinition VisibleDays="30"
                              MinorTickLength="1d"
                              FirstDayOfWeek="Monday"
                              StretchGroupHeaders="True"
                              StretchAppointments="True">
            <t:TimelineViewDefinition.GroupTickLength>
                <csv:MonthlyTickProvider />
            </t:TimelineViewDefinition.GroupTickLength>
            <t:TimelineViewDefinition.MajorTickLength>
                <csv:WeeklyTickProvider />
            </t:TimelineViewDefinition.MajorTickLength>
        </t:TimelineViewDefinition>
</t:RadScheduleView.ActiveViewDefinition>

 

Hope this will help someone.

PS: english is not my native language. Sorry if I made mistakes.

Tags
ScheduleView
Asked by
Sebastiano
Top achievements
Rank 1
Answers by
Konstantina
Telerik team
Maxime
Top achievements
Rank 1
Share this question
or