This is a migrated thread and some comments may be shown as answers.

Custom StringFormat

1 Answer 63 Views
TimeSpanPicker
This is a migrated thread and some comments may be shown as answers.
Tony
Top achievements
Rank 1
Tony asked on 01 Apr 2016, 04:29 PM

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?

1 Answer, 1 is accepted

Sort by
0
Nasko
Telerik team
answered on 05 Apr 2016, 10:42 AM
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..." >
    <telerik:RadTimeSpanPicker.TimeSpanComponents>
        <telerik:DayTimeSpanComponent/>
        <telerik:HourTimeSpanComponent/>
        <telerik:MinuteTimeSpanComponent/>
        <telerik:SecondTimeSpanComponent/>
        <telerik:MillisecondTimeSpanComponent/>
    </telerik:RadTimeSpanPicker.TimeSpanComponents>
</telerik:RadTimeSpanPicker>

Hope this helps.

Regards,
Nasko
Telerik
Do you need help with upgrading your AJAX, WPF or WinForms project? Check the Telerik API Analyzer and share your thoughts.
Tags
TimeSpanPicker
Asked by
Tony
Top achievements
Rank 1
Answers by
Nasko
Telerik team
Share this question
or