Custom StringFormat

2 posts, 0 answers
  1. Tony
    Tony avatar
    19 posts
    Member since:
    Jul 2015

    Posted 01 Apr 2016 Link to this post

    Hi Telerik,

    I really like how the TimeSpanPicker has a "StringFormat" property on it, but I'm having challenges getting it to do what I want.

    I want the selected timespan to show as:

    "x Days and y Hours".

    StringFormats like the following aren't working:

    {0:d} Days and {0:h} Hours

    Can you please help me out?  what do I need to do to make it show the way I want it to?

  2. Nasko
    Nasko avatar
    715 posts

    Posted 05 Apr 2016 Link to this post

    Hello Tony,

    You need to set the following StringFormat in order to make the timespan visualize as expected:
    <telerik:RadTimeSpanPicker x:Name="Duration"
                            Value="{Binding SelectedDuration, Mode=TwoWay}"
                            StringFormat="d' Days and 'h' hours'"
                            TimeSpanWatermarkContent="Select duration..." >

    Hope this helps.

    Do you need help with upgrading your AJAX, WPF or WinForms project? Check the Telerik API Analyzer and share your thoughts.
Back to Top