String format to display only years

4 posts, 0 answers
  1. Avi Avni
    Avi Avni avatar
    98 posts
    Member since:
    Feb 2010

    Posted 12 Dec 2010 Link to this post

    Hello

    I need to display in the date picker only the years.

    I use the Date Selection Mode="Year" but in the text box it Still show the all date.

    I try to give string format it not work.

    How can I solve this problem?

    Best regards

    Ehud

     

  2. Kaloyan
    Admin
    Kaloyan avatar
    920 posts

    Posted 14 Dec 2010 Link to this post

    Hi Ehud Pinchas,

    You have to specify an explicit ShortDatePattern in order to display a custom format string. Follow the posted code:

    timePicker.Culture = new System.Globalization.CultureInfo("en-US");
                timePicker.Culture.DateTimeFormat = new System.Globalization.DateTimeFormatInfo
                {
                    ShortDatePattern = "yyyy"
                };


    All the best,
    Kaloyan
    the Telerik team
    Browse the videos here>> to help you get started with RadControls for WPF
  3. UI for WPF is Visual Studio 2017 Ready
  4. Inge
    Inge avatar
    4 posts
    Member since:
    Jul 2013

    Posted 19 Mar 2014 Link to this post

    Hi,

    I'm facing the same issue, when I set the above mentioned solution in my code behind, it changes every datepicker on the page, but I need this string format on only one datepicker..
    Any suggestions?

    Inge
  5. Inge
    Inge avatar
    4 posts
    Member since:
    Jul 2013

    Posted 19 Mar 2014 Link to this post

    Never mind, the culture is a ref field. So if you pass the current thread culture it will change the notation of the current thread culture and apply it throughout the application.
    So if you want to set the same culture as the current thread, use new CultureInfo(Thread.CurrentThread.CurrentCulture.Name)
Back to Top