Welcome to WindowsClient.net | Sign in | Join

WPF Toolkit: Calendar & DatePicker Walkthrough

The WPF team is excited to release version 1 of our new WPF Calendar and DatePicker control starting on Monday, October 27, 2008! Binaries and source code for the Calendar and DatePicker can be downloaded at the WPF Codeplex site.

Feature Walkthrough

Version 1 of the WPF DatePicker and Calendar include many of the features that Line-of-Business (LOB) application authors need to create rich end-user experiences for viewing and selecting their dates. Features such as BlackoutDates, Multi-Range Selection, and built-in functionality like keyboard navigation will help developers get their applications up and running quickly. Developers can also create unique, branded experiences using the DatePicker and Calendar’s styling features and advanced options such custom display ranges and week day orderings. The following is a walkthrough of the major Calendar and DatePicker features explaning how to use them in your application.

Blackout Dates

The Calendar and DatePicker controls let one specify dates that are not considered acceptable dates for selection according to business rules. By default, no dates are off limits but with just a few simple lines of XAML the controls indicate the specified Blackout dates.

  <c:Calendar>
        <c:DatePicker.BlackoutDates>
            <c:CalendarDateRange Start="4/1/2008" End="4/6/2008"/>
            <c:CalendarDateRange Start="4/14/2008" End="4/17/2008"/>
        </c:DatePicker.BlackoutDates>
    </c:Calendar>
 
    <c:DatePicker>
        <c:DatePicker.BlackoutDates>
            <c:CalendarDateRange Start="4/1/2008" End="4/6/2008"/>
            <c:CalendarDateRange Start="4/14/2008" End="4/17/2008"/>
        </c:DatePicker.BlackoutDates>
    </c:DatePicker>
WPF Toolkit: Calendar & DatePicker Walkthrough Screenshot

Selection Modes

The Calendar provides four modes of selection:

  • SingleDate
  • SingleRange
  • MultipleRange
  • None

Each of these specifies how date selection can be performed in the Calendar or DatePicker. SingleDate, the only option available for the DatePicker, only permits the user to select one day. SingleRange selection permits a single contiguous selection of sequential dates while MultipleRange selection removes this limitation and permits multiple ranges of any size. Below is an example of a Calendar using Multiple Range selection.

    <c:Calendar SelectionMode="MultipleRange" />
    
WPF Toolkit: Calendar & DatePicker Walkthrough Screenshot

First Day of the Week

The Calendar and DatePicker permit an alternate starting day of the week for those that prefer to change the default of Sunday

    <c:Calendar FirstDayOfWeek="Monday" />
    <c:DatePicker FirstDayOfWeek="Monday" />
    
WPF Toolkit: Calendar & DatePicker Walkthrough Screenshot

Display Date

The Calendar and DatePicker, by default, initially displays Today’s date but if another default date is preferred one can set the DisplayDate to something else in the Calendar’s declaration.

    <c:Calendar DisplayDate="10/17/2008" />
    

Display Mode

The Calendar and DatePicker provide three modes for the calendar allowing the user to navigate to their intended date simply and quickly.

The three modes provided are:

  • Month Mode (the default shown so far)
  • Year Mode
  • Decade Mode

By clicking the Header Button (which displays viewable Month, Year, or Decade) one can change the display mode of the Calendar or DatePicker from Month Mode to Year Mode, allowing one to navigate in one-year increments; Clicking the button again will change the mode to Decade Mode, allowing one navigate in decade-long increments. To navigate back to a specific date from Decade Mode the user clicks the appropriate year button to return to Year Mode then the appropriate month button to return to Month Mode. The images below show Year Mode (on the left) and Decade Mode (on the right). The arrow points to the Header Button used for navigating Display Modes.

WPF Toolkit: Calendar & DatePicker Walkthrough Screenshot

Styling & Design Time

The Calendar and DatePicker have a design time experience for both Expression Blend and the Visual Studio WPF Designer. Use the WPF Designer to quickly set your properties or Blend to dive into the templates to create a truly customized look and feel for your users.

WPF Toolkit: Calendar & DatePicker Walkthrough Screenshot

Get Started with Calendar and DatePicker

Version 1 of the WPF Calendar and DatePicker include all of the above features and more. Check out the Calendar and DatePicker in the WPF Toolkit on www.codeplex.com/wpf starting October 28th!

Comments: 31

You must Login to comment.
 

superlloyd: On October 31, 2008 12:39 AM said:

Where could we download the sample (the one you took the screenshot from)?

 
 

sureshsuresh: On November 1, 2008 12:46 AM said:

Man, this we call, how to frustrate users on this forum, I am also looking for a control, but there is no sign where it is.

 
 

dawid.lazinski: On November 1, 2008 5:52 PM said:

A sample application and Hands-on-Lab which uses the WPF Ribbon can be found at http://windowsclient.net/wpf under "WPF Features Preview Hand-on-Lab."

 
 

Scott Bruno: On November 4, 2008 2:57 PM said:

Guess it should have read, "A couple of screenshots are available at http://windowsclient.net/wpf under "WPF Features Preview Hand-on-Lab.""

 
 

jytylr: On November 5, 2008 3:43 PM said:

In order to access Ribbon, click on "License the Office UI" and sign the licensing agreement. The Ribbon download will be available on the page after signing the license.

profile.microsoft.com/.../wizard.aspx

 
 

ttriguero: On November 6, 2008 4:46 PM said:

It would be nice to know how to set things like the SelectedDate to today.  So that the textbox displays today's date instead of Show Calendar.  I am using Blend and it is not clear as to how to do this.

 
 

Gavin99: On November 7, 2008 12:33 PM said:

More importantly, how do I use this in code? I.e. where can I find out about the methods, properties and events I can call on this control?

 
 

Gavin99: On November 10, 2008 12:43 PM said:

And how do you associate a calendar with a datepaicker? Nest them in the XAML? And how do you set the calendar to Year mode only?

So many questions? Toolkit plus demo of all features would have been nice. Or some document to take the guess work on cutting fresh code ourselves.

 
 

Gavin99: On November 12, 2008 12:34 PM said:

More observations. IsEnabled is not supported and Visibility cannot be set on this control. So when can we expect SP1 for the date picker;-)

 
 

kuehner75: On November 13, 2008 8:46 AM said:

When building the customizin list of the quick access bar, you should use the ToolTipTitle as menu text rather than the LableTitle.

I keep the lable title very short and it is only useful within the context of the group title. But this is not existing in the customizing menu.

 
 

dm1976: On November 13, 2008 8:54 AM said:

Can the calendar and/or datepicker also show the weeknumbers. Most car manufactures provide dealers the weeknumber when a car is delivered. Currently the dealer has a maskedtextbox for the weeknumber, but a datepicker would be much better..

 
 

Gavin99: On November 13, 2008 2:45 PM said:

Yet another obeservation;-)

How do we set the date format for the datepicker, other than the supplied short and long enumerations that are based off of my local regional settings? E.g. I'm developing on a machine with a local date format of dd/mm/yyyy, but I want the datepicker in my app to show mm/dd/yyyy.

SP1 - soon please!

 
 

xcosmin: On November 14, 2008 5:00 AM said:

i want on focus to change the border of datepicker in orange? could i do this with style? thanks

 
 

Samantha-Msft: On November 14, 2008 7:28 PM said:

superlloyd,

You can find a sample using Ribbon in the Hands-on-Lab “What’s Coming in WPF: DataGrid, Ribbon, and VSM” here: windowsclient.net/.../entry76491.aspx

Thanks!

Samantha

 
 

Samantha-Msft: On November 14, 2008 7:30 PM said:

sureshsuresh & Scott Bruno,

In order to get the control (even for use in the lab), you’ll need to download it from the Office UI Licensing Site.  You can find step-by-step instructions for downloading Ribbon here: www.codeplex.com/.../View.aspx

Thanks!

Samantha

 
 

Samantha-Msft: On November 14, 2008 7:32 PM said:

ttriguero, Gavin99, kuehner75, dm1976, & xcosmin,

If you have technical questions, possible bugs, or other feedback about the Ribbon or any of the WPF Toolkit components (DataGrid, DatePicker/Calendar, VisualStateManager), please post them to the WPF Codeplex site Discussions forum here: http://www.codeplex.com/wpf/Thread/List.aspx">www.codeplex.com/.../List.aspx.  This site is read daily by the member of the WPF Tree Services/Controls team.  You will likely find the answers to many of your questions in the various threads in the Discussions and we’d be more than happy to try to answer any new questions that you post.

Since we recently released the Ribbon and the WPF Toolkit including DataGrid, DatePicker/Calendar, and VisualStateManager out of band, unfortunately there is no “official” documentation for these new features available besides what you find at http://windowsclient.net/wpf/ and on the WPF Codeplex site at http://www.codeplex.com/wpf.  Official MSDN documentation will be available with .NET 4.0.

Thanks!

Samantha

 
 

Redmist: On February 16, 2009 3:57 AM said:

I'm having trouble understanding why these sorts of WPF controls aren't sizeable.  Isn't that the whole point of WPF; to have vector-based controls?  The default WinForms calendar in Vista looks nicer than this one.

 
 

life_for_rent: On March 17, 2009 4:38 AM said:

I cant find the way to set date format for datepicker.

I use datagrid and put the datepicker into it and I want to change the format day like dd/MM/yyyy in the datagrid, but I can not do this. Does this release support it? Help me!Plz

Thanks.

 
 

mallan: On March 23, 2009 6:36 AM said:

life_for_rent, I managed to do this by setting the lang property in the xaml.

i.e.

xml:lang="en-GB"

This will give you the British date and time format i.e. dd/MM/yyyy

 
 

amna.alkaabi: On March 29, 2009 5:42 AM said:

May I know if this control support muli-language or not such as French and Arabic?

 
 

baalbert: On April 8, 2009 10:22 AM said:

Do you plan to add week numbers to the calendar?

 
 

brian.shapiro: On April 9, 2009 3:44 PM said:

Is there an easy way to create a split button with a toggle state, like with the Track Changes button  in word?

 
 

asiddiqui: On June 18, 2009 2:51 PM said:

I am trying to set the date in dd/MM/yyyy format as "mallan" suggested but it does not look to be working for me.

Here is my xaml:

<my:DatePicker xml:lang="en-GB" SelectedDate="{Binding Path=date}" SelectedDateFormat="Short" />

Can someone point out what is incorrect?

 
 

SohelElite: On July 16, 2009 7:48 AM said:

In order to set date in dd/MM/yyyy format u need to add the following code on selecteddatechange event:

Private Sub DatePicker1_SelectedDateChanged(ByVal sender As Object, ByVal e As System.Windows.Controls.SelectionChangedEventArgs) Handles DatePicker1.SelectedDateChanged

       DatePicker1.SelectedDate = DatePicker1.SelectedDate.Value.ToString("dd/MM/yyyy")

End Sub

 
 

kiran.chand@live.in: On July 18, 2009 11:12 AM said:

No SOURCE CODE to download?

This is bad

Get me the working source code please!

 
1 2 Next >

Featured Item

Microsoft Communities