Universal Windows Platform (UWP)
A Microsoft platform for building and publishing apps for Windows desktop devices.
2,993 questions
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
Is there any way to add weeknumbers to the left of the calendar?
Hello,
The default CalendarView
does not contain weeknumbers property, For your requirement, you could calculate week number manually. You could use the following code to get weeknumbers with specific DateTime
.
public static int GetIso8601WeekOfYear(DateTime time)
{
DayOfWeek day = CultureInfo.InvariantCulture.Calendar.GetDayOfWeek(time);
if (day >= DayOfWeek.Monday && day <= DayOfWeek.Wednesday)
{
time = time.AddDays(3);
}
// Return the week of our adjusted day
return CultureInfo.InvariantCulture.Calendar.GetWeekOfYear(time, CalendarWeekRule.FirstFourDayWeek, DayOfWeek.Monday);
}
Call above method when you select the Date from CalendarView
private void MyCalendarView_SelectedDatesChanged(CalendarView sender, CalendarViewSelectedDatesChangedEventArgs args)
{
var date = args.AddedDates.First().DateTime;
var numberOfWeek = GetIso8601WeekOfYear(date);
}
Thanks,
Nico