Hello,
I have used the SDK Samples browser example MonthTickProvider and obtained the CustomMonthTickProvider class to display the Month names in the GroupTickLength. On similar lines, I have managed to create Weekly tick provider that displays the Week Number and Quarter tick provider that displays the Quarter of the year. These providers alone work fine when put as GroupTickLegth.
However, I have to display Week tick provider in the MajorTickLength along with Month in GroupTickLength. The user can also switch between having Month in MajorTickLength and Quarter in GroupTickLength.
I tried the change the SDK Browser example itself and I am facing must be non-negative.
The following code block is what I am trying to achieve:
<
telerik:RadScheduleView
AppointmentsSource
=
"{Binding Appointments, Source={StaticResource ViewModel}}"
>
<
telerik:RadScheduleView.ViewDefinitions
>
<
telerik:TimelineViewDefinition
VisibleDays
=
"365"
MinTimeRulerExtent
=
"8000"
>
<
telerik:TimelineViewDefinition.GroupTickLength
>
<
example:CustomMonthTickProvider
/>
</
telerik:TimelineViewDefinition.GroupTickLength
>
<
telerik:TimelineViewDefinition.MajorTickLength
>
<
example:WeeklyTickProvider
/>
</
telerik:TimelineViewDefinition.MajorTickLength
>
</
telerik:TimelineViewDefinition
>
</
telerik:RadScheduleView.ViewDefinitions
>
</
telerik:RadScheduleView
>
If we replace the MajorTickLength with the same provider as in GroupTickLength, then there is no exception raised.
Here are my Week and Quarter provider classes
public class WeeklyTickProvider : ITickProvider
{
public string GetFormatString(IFormatProvider formatInfo, string formatString, DateTime currentStart)
{
var weekNumber = GetWeekNumber(formatInfo as CultureInfo, currentStart);
return string.Format(formatInfo, "Week {0}", weekNumber);
}
private static int GetWeekNumber(CultureInfo formatInfo, DateTime currentStart)
{
var cultureInfo = formatInfo as CultureInfo;
if (cultureInfo != null)
{
return cultureInfo.Calendar.GetWeekOfYear(currentStart, cultureInfo.DateTimeFormat.CalendarWeekRule, cultureInfo.DateTimeFormat.FirstDayOfWeek);
}
return 0;
}
public DateTime GetNextStart(TimeSpan pixelLength, DateTime currentStart)
{
var currentDate = currentStart.Date;
var weekStart = CalendarHelper.GetFirstDayOfWeek(currentStart, DayOfWeek.Monday);
if (weekStart == currentDate)
{
return weekStart.AddDays(7);
}
return weekStart;
}
}
public class QuarterTickProvider : ITickProvider
{
public string GetFormatString(IFormatProvider formatInfo, string formatString, DateTime currentStart)
{
if (currentStart.Month >= 10)
{
return "Quarter 4";
}
else if (currentStart.Month >= 7)
{
return "Quarter 3";
}
else if (currentStart.Month >= 4)
{
return "Quarter 2";
}
else if (currentStart.Month >= 1)
{
return "Quarter 1";
}
return string.Empty;
}
public DateTime GetNextStart(TimeSpan pixelLength, DateTime currentStart)
{
if (currentStart.Month >= 10)
{
return new DateTime(currentStart.Year + 1, 1, 1);
}
else if (currentStart.Month >= 7)
{
return new DateTime(currentStart.Year, 10, 1);
}
else if (currentStart.Month >= 4)
{
return new DateTime(currentStart.Year, 7, 1);
}
else if (currentStart.Month >= 1)
{
return new DateTime(currentStart.Year, 4, 1);
}
return DateTime.Today;
}
Another thing I noticed is that in the above , if I set GroupTick as month and MinorTick as , then there is no exception raised, But the desired output is not achieved.
Is there any way I could provide both GroupTickLength and MajorTickLength as my own custom tick providers. I have spent a lot of time to find a way but did not achieve the desired result.