This question is locked. New answers and comments are not allowed.
I've got some problems during change displaytext while changing format, would someone help?
questions are:
1. Error occurs when i choose combobox to "Day";
2. i want to change the display text while the combobox.selectionchanged fired, actually it's never happend.
for example, when i changed to "day", it would display "2012-03-29", the display "2012" when changed to "year".
3.when i changed from "Day" to "Year", the current year become "2009" but not "2012" when the dropdown is open ,do i got sth wrong?
your help would be appreciated, thanks!
<
telerik:HeaderedContentControl
Height
=
"194"
HorizontalAlignment
=
"Left"
Margin
=
"316,241,0,0"
Name
=
"headeredContentControl1"
VerticalAlignment
=
"Top"
Width
=
"277"
>
<
StackPanel
Orientation
=
"Horizontal"
>
<
ComboBox
Name
=
"comboMode"
Width
=
"140"
SelectionChanged
=
"comboMode_SelectionChanged"
></
ComboBox
>
<
telerik:RadDatePicker
Width
=
"120"
Name
=
"dtPicker"
></
telerik:RadDatePicker
>
</
StackPanel
>
</
telerik:HeaderedContentControl
>
public
MainPage()
{
InitializeComponent();
this
.Loaded +=
new
RoutedEventHandler(MainPage_Loaded);
}
void
MainPage_Loaded(
object
sender, RoutedEventArgs e)
{
dtPicker.Culture =
new
System.Globalization.CultureInfo(Thread.CurrentThread.CurrentUICulture.Name); // actually is "zh-cn"
SetData();
}
private
void
SetData()
{
IDictionary<
string
,
string
> dic =
new
Dictionary<
string
,
string
>();
dic.Add(
"Day"
,
"日"
);
dic.Add(
"Month"
,
"月"
);
dic.Add(
"Year"
,
"年"
);
comboMode.ItemsSource = dic;
comboMode.DisplayMemberPath =
"Value"
;
comboMode.SelectedValuePath =
"Key"
;
}
private
void
comboMode_SelectionChanged(
object
sender, SelectionChangedEventArgs e)
{
string
item = comboMode.SelectedValue.ToString();
switch
(item)
{
case
"Day"
:
dtPicker.DateSelectionMode = DateSelectionMode.Day;
dtPicker.Culture.DateTimeFormat.ShortDatePattern =
"yyyy年MM月dd日"
;
// sounds invalid?
break
;
case
"Month"
:
dtPicker.DateSelectionMode = DateSelectionMode.Month;
//dtPicker.Culture.DateTimeFormat.ShortDatePattern = "yyyy年MM月";
dtPicker.Culture.DateTimeFormat.ShortDatePattern =
"yyyy-MM"
;
break
;
case
"Year"
:
dtPicker.DateSelectionMode = DateSelectionMode.Year;
dtPicker.Culture.DateTimeFormat.ShortDatePattern =
"yyyy"
;
break
;
}
}
questions are:
1. Error occurs when i choose combobox to "Day";
2. i want to change the display text while the combobox.selectionchanged fired, actually it's never happend.
for example, when i changed to "day", it would display "2012-03-29", the display "2012" when changed to "year".
3.when i changed from "Day" to "Year", the current year become "2009" but not "2012" when the dropdown is open ,do i got sth wrong?
your help would be appreciated, thanks!