This is a migrated thread and some comments may be shown as answers.

how to bind to calendar's DisplayDateChanged event ?

1 Answer 128 Views
DateTimePicker
This is a migrated thread and some comments may be shown as answers.
Missing User
Missing User asked on 23 Jan 2013, 10:35 AM
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) 

1 Answer, 1 is accepted

Sort by
0
Vladi
Telerik team
answered on 25 Jan 2013, 02:52 PM
Hello Hui,

We responded to you in the support ticket with ID 651963 for the same issue. Could we continue the discussion there?

I will post the response from that thread here too in order for it to be available for the community:

In order to access the DisplayDateChanged event of the Calendar in the DateTimePicker control you should use the Style of the RadDateTimePicker not the CalendarStyle. Placing RadCalendar control in the Template of the RadCalendar is not a supported scenario in the control.

All the best,
Vladi
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

Tags
DateTimePicker
Asked by
Missing User
Answers by
Vladi
Telerik team
Share this question
or