how to bind to calendar's DisplayDateChanged event ?

2 posts, 0 answers
  1. Missing user
    Missing user avatar

    Posted 23 Jan 2013 Link to this post

    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) 
  2. Vladi
    Admin
    Vladi avatar
    744 posts

    Posted 25 Jan 2013 Link to this post

    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.

  3. UI for WPF is Visual Studio 2017 Ready
Back to Top