Search code examples
.netwpfvb.netwpf-controls

Difference between Calendar & Date Picker control in WPF?


Difference between Calendar & Date Picker control in WPF? Is there any criteria of choosing the either of them?


Solution

  • Per the DatePicker documentation:

    The DatePicker control allows the user to select a date by either typing it into a text field or by using a drop-down Calendar control.

    Many of a DatePicker control's properties are for managing its built-in Calendar, and function identically to the equivalent property in Calendar. [snip] For more information, see Calendar.

    The Calendar links in that documentation lead directly to the WPF Calendar control, so...

    From my understanding, the DatePicker is essential a control that contains a calendar that is not visible until the user clicks on the drop-down, while the calendar is always visible, unless you provide additional markup and code to achieve the same effect.

    So you'd use a calendar when you want a full calendar visible on the page at all times, and a DatePicker when you want something more compact.

    When using it to select dates, personally, I'd always choose the DatePicker unless I had a reason to display the calendar. For example, if I were creating an app that lets me enter my birthday a s a part of the registration process, I'd use a DatePicker.

    I might use the Calendar in a schedule app, or an appointment calendar. Such an app may have additional data displayed in each day, representing appointments or scheduled shifts. IN that case, I'd want it always visible.

    But really, which to use is a per-app design decision.