How to change displaytext while changing format

1 posts, 0 answers
  1. Christin
    Christin avatar
    1 posts
    Member since:
    Sep 2011

    Posted 29 Mar 2012 Link to this post

    I've got some problems during change displaytext while changing format, would someone help?

    <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>
    public MainPage()
         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"

     private void SetData()
         IDictionary<string,string> dic = new Dictionary<string,string>();
         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?             
             case "Month":
                 dtPicker.DateSelectionMode = DateSelectionMode.Month;
                 //dtPicker.Culture.DateTimeFormat.ShortDatePattern = "yyyy年MM月";
                 dtPicker.Culture.DateTimeFormat.ShortDatePattern = "yyyy-MM";
             case "Year":
                 dtPicker.DateSelectionMode = DateSelectionMode.Year;
                 dtPicker.Culture.DateTimeFormat.ShortDatePattern = "yyyy";             

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