Show decade popup first

5 posts, 0 answers
  1. Andrew
    Andrew avatar
    39 posts
    Member since:
    Feb 2011

    Posted 24 Jul 2013 Link to this post

    Software we are writing with WPF has some requirements to enter dates which are 10-20 years in the future. Ideally, we would like the FIRST popup to be the decade view, but which would then continue down to the month, then day - much like if you click on the header part several times. We don't want the control to ONLY take a year, so DateSelectionMode set to 'Year' is not what we want.

  2. Ventzi
    Admin
    Ventzi avatar
    114 posts

    Posted 29 Jul 2013 Link to this post

    Hello Andrew,

    You could create a CalendarStyle in which you could set the DisplayMode property to CenturyView. Then you should apply the style when DropDownOpened event of the RadDateTimePicker occurs, because only then is the calendar part fully loaded.   

    I've attached a sample project which demonstrates this approach.

    Regards,
    Ventzi
    Telerik
    TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for WPF.
    Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
    Sign up for Free application insights >>
  3. UI for WPF is Visual Studio 2017 Ready
  4. Andrew
    Andrew avatar
    39 posts
    Member since:
    Feb 2011

    Posted 29 Jul 2013 Link to this post

    That's fantastic - just what I needed to point me in the right direction - in fact, I ultimately approached it slightly differently, with my own DatePicker class which subclasses yours. This way - I can default for all the date controls in my project, but can override in the XAML for those that we want to act normally.
    Public Class MyDatePicker
        Inherits Telerik.Windows.Controls.RadDatePicker
     
        Private Sub MyDatePicker_DropDownOpened(sender As Object, e As RoutedEventArgs) Handles Me.DropDownOpened
            Dim oStyle = New Style(GetType(RadCalendar))
            oStyle.Setters.Add(New Setter(RadCalendar.DisplayModeProperty, Me.CalendarDisplayMode))
            Me.CalendarStyle = oStyle
        End Sub
     
        Private _CalendarDisplayMode As Calendar.DisplayMode = Calendar.DisplayMode.DecadeView
        Public Property CalendarDisplayMode() As Calendar.DisplayMode
            Get
                Return _CalendarDisplayMode
            End Get
            Set(value As Calendar.DisplayMode)
                _CalendarDisplayMode = value
            End Set
        End Property
    End Class
  5. Andrew
    Andrew avatar
    39 posts
    Member since:
    Feb 2011

    Posted 13 Aug 2013 Link to this post

    Actually - there is a problem with your and my approach - because the CalendarStyle can only be set once, before the Calendar popup is fully loaded. Once this has happened, and you've set a value, the subsequent popups are always at the Day level. Now, this SHOULD be the case when there is a selected date (the popup should be at that date), but if you clear the value in the control, the popup ideally would then go back to the Decade view. Is there any way to achieve this?

  6. Yana
    Admin
    Yana avatar
    4554 posts

    Posted 19 Aug 2013 Link to this post

    Hello Andrew,

    I've updated the project to demonstrate how you could switch the DisplayMode when there is no SelectedValue in the DateTimePicker control.

    I hope this solution will work in your scenario as well.

    Regards,
    Yana
    Telerik
    TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for WPF.
    Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
    Sign up for Free application insights >>
Back to Top
UI for WPF is Visual Studio 2017 Ready