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

4 posts, 0 answers
  1. b
    b avatar
    9 posts
    Member since:
    Sep 2010

    Posted 06 Dec 2011 Link to this post

    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!
  2. Konstantina
    Admin
    Konstantina avatar
    2332 posts

    Posted 09 Dec 2011 Link to this post

    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 >>
  3. DevCraft banner
  4. b
    b avatar
    9 posts
    Member since:
    Sep 2010

    Posted 09 Dec 2011 Link to this post

    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!
  5. Konstantina
    Admin
    Konstantina avatar
    2332 posts

    Posted 14 Dec 2011 Link to this post

    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 >>
Back to Top