'How Can I Disable Year Selection in WPF Calendar

  • I want to make a calendar like Google's Calendar to Show all days of the year in one screen.
    • I will use 12 Calendar instances.
  • I want To disable the year selection from the header of the WPF Calendar to look like a label, rather than a clickable button.

WPF Calendar



Solution 1:[1]

You can do this by setting the DisplayDateStart and the DisplayDateEnd properties of The Calender Control.

For example in XAML, you could do:

<Calendar DisplayDateStart="1/1/2022" DisplayDateEnd="31/12/2022"/>

Or in code-behind:

Calendar cal = new Calendar();
cal.DisplayDateStart = new DateTime(2022, 1, 1);
cal.DisplayDateEnd = new DateTime(2022, 12, 31);

Limitations: This only restricts the display range, as pointed out int the comment.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1