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

How to show year only

4 Answers 165 Views
DatePicker
This is a migrated thread and some comments may be shown as answers.
Yang
Top achievements
Rank 1
Yang asked on 19 Sep 2011, 10:41 PM
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

 

4 Answers, 1 is accepted

Sort by
0
Konstantina
Telerik team
answered on 21 Sep 2011, 04:11 PM
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 >>
0
Syed
Top achievements
Rank 1
answered on 03 Jan 2013, 03:45 PM
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
0
Syed
Top achievements
Rank 1
answered on 04 Jan 2013, 01:08 PM
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";

0
Dustin
Top achievements
Rank 1
answered on 16 Oct 2014, 04:30 PM
Thank you, this is very close to what I need.  Would you mind showing how to do this in XAML?  

Thanks again.
Tags
DatePicker
Asked by
Yang
Top achievements
Rank 1
Answers by
Konstantina
Telerik team
Syed
Top achievements
Rank 1
Dustin
Top achievements
Rank 1
Share this question
or