Derik Whittaker



Using the DatePicker Control in WP7

With the final release of the Windows Phone 7 Development tools there was also a release of the WP7 Control Toolkit which provides us a set of standard controls such as:

  • GestureService/GestureListener
  • ContextMenu
  • DatePicker
  • TimePicker
  • ToggleSwitch
  • WrapPanel


The control we want to focus on here is the DatePicker.  With the DatePicker control there is now a standard UX control which fits the design metaphor of WP7 (seen below).


Now that we have this new control how do we use it in our applications?  The great news for you is that using is dead simple.

  1. Make sure you download and install the toolkit from codeplex
  2. Add a reference to the Microsoft.Phone.Controls.Toolkit assembly in your project
  3. In your xaml class make sure you add a reference to the DatePicker assembly as follows
  4. In your xaml class make sure you reference the DatePicker as follows
    <Controls:DatePicker />
  5. Now you have the DatePicker up and running.

Of course the above is the bare minimum you need to get the picker working.  But what if I want to:

  1. Set a default value
  2. Bind to the value of the control
  3. Handle the value changed event (this gives you access to the original value and the new value)

To set the default value (with no binding) you can do the following:
<Controls:DatePicker Value="01/01/2000" />

To Bind to the value you can do the following:
<Controls:DatePicker Value="{Binding DateValue, Mode=TwoWay}" />

To Handle the value changed event you can do the following:
<Controls:DatePicker ValueChanged="DatePicker_ValueChanged" />


As you can see using the DatePicker is pretty painless and easy.

Till next time,

Posted 09-19-2010 5:49 AM by Derik Whittaker
Filed under: ,



joethecoder wrote re: Using the DatePicker Control in WP7
on 09-20-2010 11:55 AM

Looks pretty lame to me. Hope it's more stylish than this when/if it hits the phone.

Michael Fever wrote re: Using the DatePicker Control in WP7
on 09-20-2010 10:04 PM

Is it customizable?

Derik Whittaker wrote re: Using the DatePicker Control in WP7
on 09-21-2010 7:33 AM

@Michael Yes you can apply your own styles if you want.

About The CodeBetter.Com Blog Network
CodeBetter.Com FAQ

Our Mission

Advertisers should contact Brendan

Google Reader or Homepage Latest Items
Add to My Yahoo!
Subscribe with Bloglines
Subscribe in NewsGator Online
Subscribe with myFeedster
Add to My AOL
Furl Latest Items
Subscribe in Rojo

Member Projects
DimeCasts.Net - Derik Whittaker

Friends of
Red-Gate Tools For SQL and .NET


SmartInspect .NET Logging
NGEDIT: ViEmu and Codekana
NHibernate Profiler
Balsamiq Mockups
JetBrains - ReSharper
Web Sequence Diagrams
Ducksboard<-- NEW Friend!


Site Copyright © 2007 CodeBetter.Com
Content Copyright Individual Bloggers


Community Server (Commercial Edition)