How to bind to calendar's DisplayDateChanged event?
or How to refresh blackout dates when change display from January to February?
When I don't use telerik, I found a solution according to set the DatePicker.CalendarStyle, and rewrite the Calendar'sTemplate. In the Template, a new calendar is created, and so the new calendar's DisplayDateChanged event can be gained. But when using telerik radDateTimePicker, it will cause error.
<telerik:RadDateTimePicker>
<telerik:RadDateTimePicker.CalendarStyle>
<Style TargetType="telerik:RadCalendar">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate>
<telerik:RadCalendar >
<inter:Interaction.Triggers>
<inter:EventTrigger EventName="DisplayDateChanged">
<galaSoftMvvmLightCommand:EventToCommand PassEventArgsToCommand="True" Command="{Binding DisplayDateChangeCommand}" />
</inter:EventTrigger>
</inter:Interaction.Triggers>
</telerik:RadCalendar>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</telerik:RadDateTimePicker.CalendarStyle>
</telerik:RadDateTimePicker>
NullReferenceException:
Object reference not set to an instance of an object.
at Telerik.Windows.Controls.RadCalendar.UpdateRowsAndColumns() in c:\TB\102\WPF_Scrum\Release_WPF\Sources\Development\Controls\Input\Calendar\RadCalendar.cs:line 3729
at Telerik.Windows.Controls.RadCalendar.OnApplyTemplate() in c:\TB\102\WPF_Scrum\Release_WPF\Sources\Development\Controls\Input\Calendar\RadCalendar.cs:line 2062
at System.Windows.FrameworkElement.ApplyTemplate()
at System.Windows.FrameworkElement.MeasureCore(Size availableSize)
at System.Windows.UIElement.Measure(Size availableSize)
at System.Windows.Controls.Grid.MeasureCell(Int32 cell, Boolean forceInfinityV)
at System.Windows.Controls.Grid.MeasureCellsGroup(Int32 cellsHead, Size referenceSize, Boolean ignoreDesiredSizeU, Boolean forceInfinityV, Boolean& hasDesiredSizeUChanged)
at System.Windows.Controls.Grid.MeasureCellsGroup(Int32 cellsHead, Size referenceSize, Boolean ignoreDesiredSizeU, Boolean forceInfinityV)
at System.Windows.Controls.Grid.MeasureOverride(Size constraint)
at System.Windows.FrameworkElement.MeasureCore(Size availableSize)
at System.Windows.UIElement.Measure(Size availableSize)
at MS.Internal.Helper.MeasureElementWithSingleChild(UIElement element, Size constraint)
at System.Windows.Controls.ContentPresenter.MeasureOverride(Size constraint)
at System.Windows.FrameworkElement.MeasureCore(Size availableSize)
at System.Windows.UIElement.Measure(Size availableSize)
at System.Windows.Controls.Decorator.MeasureOverride(Size constraint)
at System.Windows.Documents.AdornerDecorator.MeasureOverride(Size constraint)
at System.Windows.FrameworkElement.MeasureCore(Size availableSize)
at System.Windows.UIElement.Measure(Size availableSize)
at System.Windows.Controls.Decorator.MeasureOverride(Size constraint)
at System.Windows.FrameworkElement.MeasureCore(Size availableSize)
at System.Windows.UIElement.Measure(Size availableSize)
at System.Windows.Controls.Primitives.PopupRoot.MeasureOverride(Size constraint)
or How to refresh blackout dates when change display from January to February?
When I don't use telerik, I found a solution according to set the DatePicker.CalendarStyle, and rewrite the Calendar'sTemplate. In the Template, a new calendar is created, and so the new calendar's DisplayDateChanged event can be gained. But when using telerik radDateTimePicker, it will cause error.
<telerik:RadDateTimePicker>
<telerik:RadDateTimePicker.CalendarStyle>
<Style TargetType="telerik:RadCalendar">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate>
<telerik:RadCalendar >
<inter:Interaction.Triggers>
<inter:EventTrigger EventName="DisplayDateChanged">
<galaSoftMvvmLightCommand:EventToCommand PassEventArgsToCommand="True" Command="{Binding DisplayDateChangeCommand}" />
</inter:EventTrigger>
</inter:Interaction.Triggers>
</telerik:RadCalendar>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</telerik:RadDateTimePicker.CalendarStyle>
</telerik:RadDateTimePicker>
NullReferenceException:
Object reference not set to an instance of an object.
at Telerik.Windows.Controls.RadCalendar.UpdateRowsAndColumns() in c:\TB\102\WPF_Scrum\Release_WPF\Sources\Development\Controls\Input\Calendar\RadCalendar.cs:line 3729
at Telerik.Windows.Controls.RadCalendar.OnApplyTemplate() in c:\TB\102\WPF_Scrum\Release_WPF\Sources\Development\Controls\Input\Calendar\RadCalendar.cs:line 2062
at System.Windows.FrameworkElement.ApplyTemplate()
at System.Windows.FrameworkElement.MeasureCore(Size availableSize)
at System.Windows.UIElement.Measure(Size availableSize)
at System.Windows.Controls.Grid.MeasureCell(Int32 cell, Boolean forceInfinityV)
at System.Windows.Controls.Grid.MeasureCellsGroup(Int32 cellsHead, Size referenceSize, Boolean ignoreDesiredSizeU, Boolean forceInfinityV, Boolean& hasDesiredSizeUChanged)
at System.Windows.Controls.Grid.MeasureCellsGroup(Int32 cellsHead, Size referenceSize, Boolean ignoreDesiredSizeU, Boolean forceInfinityV)
at System.Windows.Controls.Grid.MeasureOverride(Size constraint)
at System.Windows.FrameworkElement.MeasureCore(Size availableSize)
at System.Windows.UIElement.Measure(Size availableSize)
at MS.Internal.Helper.MeasureElementWithSingleChild(UIElement element, Size constraint)
at System.Windows.Controls.ContentPresenter.MeasureOverride(Size constraint)
at System.Windows.FrameworkElement.MeasureCore(Size availableSize)
at System.Windows.UIElement.Measure(Size availableSize)
at System.Windows.Controls.Decorator.MeasureOverride(Size constraint)
at System.Windows.Documents.AdornerDecorator.MeasureOverride(Size constraint)
at System.Windows.FrameworkElement.MeasureCore(Size availableSize)
at System.Windows.UIElement.Measure(Size availableSize)
at System.Windows.Controls.Decorator.MeasureOverride(Size constraint)
at System.Windows.FrameworkElement.MeasureCore(Size availableSize)
at System.Windows.UIElement.Measure(Size availableSize)
at System.Windows.Controls.Primitives.PopupRoot.MeasureOverride(Size constraint)