How to show year only

5 posts, 0 answers
  1. Yang
    Yang avatar
    14 posts
    Member since:
    Jun 2009

    Posted 19 Sep 2011 Link to this post

    Hi,

    I am using DateTimePicker in GridView whith MVVM pattern.

    <

     

     

    telerik:RadDateTimePicker InputMode="DatePicker" DisplayFormat="Short" DateSelectionMode="Year" DisplayDateStart="1990/01/01" SelectedValue="{Binding Year, Mode=TwoWay}"/>

    My DateSelectionMode is Year, so I can only choose year. But I need to only show year after selection.
    Please check the image. The text 1/1/2001 is not what I want. I just want 2001.
    Is this possible done using MVVM? I checked forum. It seems that solution can only be done using code behind. Also, the DateTimePicker is in GridView.

    Thanks

     

  2. Konstantina
    Admin
    Konstantina avatar
    2332 posts

    Posted 21 Sep 2011 Link to this post

    Hi Yang,

    In order to achieve this you will need to implement custom parsing. You can find more information how to do this in this help article.

    Hope this information is helpful.

    Regards,
    Konstantina
    the Telerik team
    Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>
  3. DevCraft banner
  4. Syed
    Syed avatar
    2 posts
    Member since:
    Aug 2011

    Posted 03 Jan 2013 Link to this post

    Hi,

    Even I have the same scenario where I just want to show year selected.
    I have gone through the article suggested by konstantina but it didn't work out.
    can anyone out there guide me how to get it through

    thanks
  5. Syed
    Syed avatar
    2 posts
    Member since:
    Aug 2011

    Posted 04 Jan 2013 Link to this post

    Here I got a simple solution to the above mentioned issue
    set the Culture property either in the xaml or code behind
    <telerik:RadDatePicker x:Name="yearPicker" Culture="en-US" HorizontalAlignment="Left" VerticalAlignment="Center" Width="150" Height="26" InputMode="DatePicker" SelectedValue="{Binding Model.SIStatYear,Mode=TwoWay}" SelectionChanged="RadDateTimePicker_SelectionChanged" DateSelectionMode="Year" ParseDateTimeValue="RadDateTimePicker_ParseDateTimeValue"/>
    then set the date patter like below
    this.yearPicker.Culture.DateTimeFormat.ShortDatePattern = "yyyy";

  6. Dustin
    Dustin avatar
    10 posts
    Member since:
    Sep 2014

    Posted 16 Oct 2014 in reply to Syed Link to this post

    Thank you, this is very close to what I need.  Would you mind showing how to do this in XAML?  

    Thanks again.
Back to Top
DevCraft banner