New to Telerik UI for WPF? Start a free 30-day trial
Limit selection when DateSelectionMode="Month"
Updated on Sep 15, 2025
Environment
| Product | RadDateTimePicker for WPF |
Description
How to limit selection when the DateSelectionMode property is Month.
Solution
Create a custom StyleSelector and disable the months by setting the IsEnabled property of the CalendarButtonContent. After that, set the StyleSelector to the MonthButtonStyleSelector property of the RadDateTimePicker.
C#
public class MonthSelector : StyleSelector
{
public override Style SelectStyle(object item, DependencyObject container)
{
CalendarButtonContent content = item as CalendarButtonContent;
if (content != null)
{
var monthsToEnable = new List<string>() { "Mar", "Jun", "Sep", "Dec" };
if (!monthsToEnable.Contains(content.Text))
{
content.IsEnabled = false;
}
}
return base.SelectStyle(item, container);
}
}
XAML
<Grid>
<Grid.Resources>
<local:MonthSelector x:Key="monthSelector"/>
</Grid.Resources>
<telerik:RadCalendar DateSelectionMode="Month"
MonthButtonStyle="{x:Null}"
MonthButtonStyleSelector="{StaticResource monthSelector}"/>
</Grid>