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

Show decade popup first

4 Answers 93 Views
DatePicker
This is a migrated thread and some comments may be shown as answers.
Andrew
Top achievements
Rank 1
Andrew asked on 24 Jul 2013, 01:49 PM
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.

4 Answers, 1 is accepted

Sort by
0
Ventzi
Telerik team
answered on 29 Jul 2013, 09:24 AM
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 >>
0
Andrew
Top achievements
Rank 1
answered on 29 Jul 2013, 02:37 PM
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
0
Andrew
Top achievements
Rank 1
answered on 13 Aug 2013, 12:53 PM
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?

0
Yana
Telerik team
answered on 19 Aug 2013, 12:09 PM
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 >>
Tags
DatePicker
Asked by
Andrew
Top achievements
Rank 1
Answers by
Ventzi
Telerik team
Andrew
Top achievements
Rank 1
Yana
Telerik team
Share this question
or