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

Need to allow selection of dates in "Current" and "Next" years

3 Answers 32 Views
DatePicker
This is a migrated thread and some comments may be shown as answers.
b
Top achievements
Rank 1
b asked on 06 Dec 2011, 06:23 PM
Hi,

I need to restrict the DatePicker to only show dates for the "Current" and "Next" year, and instead of the actualy numeric year I need to show the text "Current" if it's the current year and "Next" if it's the next year.

So in a nutshell: don't show year number anywhere in the DatePicker (whether the calendar or the text field), instead show the text "Current Year" if it's the current year and "Next Year" if it's the next year.

How may I accomplish this?

Thanks!

3 Answers, 1 is accepted

Sort by
0
Konstantina
Telerik team
answered on 09 Dec 2011, 03:11 PM
Hi B,

Could you please be more specific where exactly you want to change the number of the year?
Initially, this can be done be re-templating the RadCalendar control, which is part of the DatePicker. To restrict the visible dates you can set the DisplayDateStart and DisplayDateEnd properties of the DatePicker.
You can edit the template of the DatePicker very easy with Expression Blend. Just drop a DatePicker control on the design surface, right-click it and choose from the menu Edit Template->Edit a Copy. Then Blend will generate all the needed resource. Find the Button x:Name="Header" and navigate to its style: CalendarHeaderButton. There you will find the two TextBlocks which display the text. Through a converter you can change the 2011 number to "Current" and 2012 to "Next".

Hope this helps.

Kind regards,
Konstantina
the Telerik team
Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>
0
b
Top achievements
Rank 1
answered on 09 Dec 2011, 05:48 PM
Hi Konstantina,

That's close to what I want.  Could you give an example of how I'd use a converter in the header?  I tried using a converter a few days ago but it didn't work for me.

I also want to show "Current Year" and "Next Year" in the year and century views as well.  How would I do that?

Thanks!
0
Konstantina
Telerik team
answered on 14 Dec 2011, 04:06 PM
Hello B,

In order to edit the decade button, you need to right-click the RadCalendar control, which reside in the DatePicker template and choose Edit Additional Templates->Edit DecadeButtonStyle->Edit a Copy. There bind the Content property of the ContentPresenter with x:Name="Content"  and through a Converter set the proper text. You can find more information about Converters and how to create them in these help resources:

http://www.jeremybytes.com/Downloads/DataTemplatesAndConverters.pdf
http://weblogs.asp.net/psheriff/archive/2010/09/24/using-value-converters-in-silverlight.aspx
http://timheuer.com/blog/articles/silverlight-get-started-part-4-binding-data.aspx
http://sweetleets.com/blog/converters-in-silverlight-2

Best wishes,
Konstantina
the Telerik team
Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>
Tags
DatePicker
Asked by
b
Top achievements
Rank 1
Answers by
Konstantina
Telerik team
b
Top achievements
Rank 1
Share this question
or