Hi Telerik Team
I try to make my own YearPicker with additional int properties. Everything works fine except one case. When I set ShortDatePattern to 'yyyy' it displays error while typing year. When I set this pattern to 'MMMM yyyy' or even '/yyyy' it's ok and it work. But with 'yyyy' i've got parse error and SelectedDate is null. Dates from calendar work fine, only with typing there is a problem. Here is code of my class
Can anyone tell me what is the reason of this behavior and maybe solution on some workaround?
I try to make my own YearPicker with additional int properties. Everything works fine except one case. When I set ShortDatePattern to 'yyyy' it displays error while typing year. When I set this pattern to 'MMMM yyyy' or even '/yyyy' it's ok and it work. But with 'yyyy' i've got parse error and SelectedDate is null. Dates from calendar work fine, only with typing there is a problem. Here is code of my class
public
class
YearPicker : RadDatePicker
{
public
static
readonly
DependencyProperty SelectedYearProperty =
DependencyProperty.Register(
"SelectedYear"
,
typeof
(
int
),
typeof
(YearPicker),
new
PropertyMetadata(1, PropertyChangedCallback));
public
YearPicker()
{
this
.Culture =
new
CultureInfo(Thread.CurrentThread.CurrentUICulture.Name)
{
DateTimeFormat =
{
ShortDatePattern =
"/yyyy"
}
};
this
.DateSelectionMode = DateSelectionMode.Year;
if
(!SelectedDate.HasValue)
{
this
.SelectedDate =
new
DateTime(
this
.SelectedYear, 1, 1);
}
else
{
this
.SelectedYear =
this
.SelectedDate.Value.Year;
}
this
.SelectionChanged +=
this
.OnSelectionChanged;
}
public
int
SelectedYear
{
get
{
return
(
int
)
this
.GetValue(SelectedYearProperty);
}
set
{
this
.SetValue(SelectedYearProperty, value);
}
}
private
new
DateSelectionMode DateSelectionMode
{
set
{
base
.DateSelectionMode = value;
}
}
//rest of functions with SeletecYear logic
}
Can anyone tell me what is the reason of this behavior and maybe solution on some workaround?