tags:

views:

74

answers:

2

I don't quite like a few things in a regular .net 4.0 WPF DatePicker.

  • I don't like the default calendar icon that always shows '15'. Is it possible to change that, so it could show the actual selected day?

  • Is it possible to choose several days instead of a one, so when you click and calendar opens you could see all those days, and label says something lake 'august 2010' or '8/01/2010 - 8/15/2010'?

+2  A: 

I don't like the default calendar icon that alwasy shows '15'. Is it possible to change that, so it could show the actual selected day?

You need to create your own ControlTemplate. The easiest way is to take the default template (you can download it from here) and change the parts you want.

Is it possible to choose several days instead of a one, so when you click and calendar opens you could see all those days, and label says something lake 'august 2010' or '8/01/2010 - 8/15/2010'?

That would be much harder, but not impossible... You could try to inherit the existing DatePicker, but I think you will need to create your own control from scratch

Thomas Levesque
Well there is interesting thing about date range selection. If it's impossible by default, what the heck of a control this guy talks about: http://www.c-sharpcorner.com/UploadFile/mahesh/563/ ? He says about SelectionDates. Yes with 's'. But there is no such thing in date picker control. Is it posssible that MS just ripped of that functionality, but it was there before?
Ike
It is possible indeed: the DatePicker was part of the WPF toolkit, and was later added to the .NET Framework. Since the WPF toolkit version had a few bugs, perhaps they just removed that feature rather than fixing it
Thomas Levesque
A: 

Try using the Calendar control for multiple date selections. This control already has the functionality for selecting multiple dates built right into it. However, to make it look like a DatePicker, you'll have to create your own style/template.

This shouldn't be too hard though... you could start off by putting the Calendar inside of a Combobox or Expander, then restyle the ComboBox/Expander to the look you prefer.

Brent