Changing DateFormat

6 posts, 0 answers
  1. Namir Ahmed
    Namir Ahmed avatar
    6 posts
    Member since:
    Sep 2009

    Posted 21 Sep 2009 Link to this post

    Hi,

    How do I set the DateFormat in the RadDatePicker.

    For example, I want to show the date 9/7/09 as July 9, 2009 in the textbox. Any help would be appreciated.

    Thanks,
    wpfguy
  2. Namir Ahmed
    Namir Ahmed avatar
    6 posts
    Member since:
    Sep 2009

    Posted 21 Sep 2009 Link to this post

    I figured it out. Thanks.
  3. UI for WPF is Visual Studio 2017 Ready
  4. liza g
    liza g avatar
    24 posts
    Member since:
    Dec 2009

    Posted 03 May 2010 Link to this post

    How did you do that?
  5. Boyan
    Admin
    Boyan avatar
    758 posts

    Posted 05 May 2010 Link to this post

    Hello liza g,

     You can try the following code:

    CultureInfo culture = (CultureInfo)CultureInfo.CurrentCulture.Clone();
    culture.DateTimeFormat.ShortDatePattern = "MMM/dd/yyyy";
    datePicker1.Culture = culture;

    This will set the date to this format : May/06/2010.

    Let me know if you have more questions.

    Sincerely yours,
    Boyan
    the Telerik team

    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
  6. liza g
    liza g avatar
    24 posts
    Member since:
    Dec 2009

    Posted 05 May 2010 Link to this post

    but I have to do it from the XAML, 
    cause it's a DatePicker in a DataTemplate inside a gridView
    and if I set it a name, it's not recognize in the cs file.
    here is my code:
    <telerik:RadGridView>
    <telerik:RadGridView.Columns>
    <telerik:GridViewDataColumn
      <telerik:GridViewDataColumn.CellTemplate>
    <DataTemplate>
    <TextBlock Text="{Binding myDate}" />
     </DataTemplate>
     </telerik:GridViewDataColumn.CellTemplate>

    <telerik:GridViewDataColumn.CellEditTemplate>
    <DataTemplate>
    <telerikInput:RadDatePicker Loaded="Editor_Loaded" 
    SelectedDate="{Binding myDate, Mode=TwoWay}"/>
    </DataTemplate>
    </telerik:GridViewDataColumn.CellEditTemplate>
    </telerik:GridViewDataColumn>
    </telerik:RadGridView.Columns>
    <telerik:RadGridView>
  7. Kaloyan
    Admin
    Kaloyan avatar
    920 posts

    Posted 10 May 2010 Link to this post

    Hello liza g,

    You can set a global culture that will be applied to the RadDatePicker also.

    CultureInfo culutreInfo = System.Threading.Thread.CurrentThread.CurrentCulture.Clone() as CultureInfo;
    culutreInfo.DateTimeFormat.ShortDatePattern = "MMM dd/yyyy";
    System.Threading.Thread.CurrentThread.CurrentCulture = culutreInfo;

    Best wishes,
    Kaloyan
    the Telerik team

    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
Back to Top
UI for WPF is Visual Studio 2017 Ready