TimeSpan Picker DisplayStringFormat

1 Answer 101 Views
TimeSpanPicker
Hakob
Top achievements
Rank 2
Iron
Hakob asked on 29 Aug 2022, 11:35 AM
Hello, for the timeSpan Picker spinner I am using this "dd\\:hh\\:mm" format, after selecting I wanna show a different display format, how can I use DisplayStringFormat to show just Hours and Minutes, the form should be like this "hh: mm"?

1 Answer, 1 is accepted

Sort by
0
Accepted
Didi
Telerik team
answered on 29 Aug 2022, 02:44 PM

Hi,

DisplayStringFormat should be set to: 

<telerikInput:RadTimeSpanPicker DisplayStringFormat="hh\:mm"/>

Regards,
Didi
Progress Telerik

Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.

Hakob
Top achievements
Rank 2
Iron
commented on 30 Aug 2022, 07:51 AM

Thank you for the answer, but this way I lose the day's information, I want to keep all info and convert it to the Hours and minutes.
Didi
Telerik team
commented on 30 Aug 2022, 07:58 AM

Hi,

The display string format just shows the desired format when the time interval was picked. The complete information about the time interval is inside the Time property. Please review the TimeSpanPicker documentation: https://docs.telerik.com/devtools/xamarin/controls/timespanpicker/timespan-picker-key-features#current-selected-time-interval 
What will be displayed in the spinners (when the popup is opened) is managed from the SpinnerFormat property. https://docs.telerik.com/devtools/xamarin/controls/timespanpicker/timespan-picker-format-string 

If you have any additional questions on this, please open a support ticket and attach a sample code to it. 

Hakob
Top achievements
Rank 2
Iron
commented on 30 Aug 2022, 11:24 AM

To implement custom DisplayStringFormat I used Label and disabled Visibility for RadTimeSoanPicker. Instead of the Spinner opening process, I used Tapping on the Label, I used TapGestureRecognizer, and Toggle Command.Execute(Value)  for the Focus.
Didi
Telerik team
commented on 31 Aug 2022, 07:22 AM

If you are using a DisplayTemplate then you have to set the text inside the template as follows:

<ControlTemplate x:Key="displayTemplate">
                <Button Text="{TemplateBinding DisplayString}" 
                        TextColor="White" 
                        BackgroundColor="#70B8FF"
                        HeightRequest="50"
                        Command="{TemplateBinding ToggleCommand}" />
            </ControlTemplate>

no matter whether it is a button or label, the text should be TemplateBinding to DisplayString

Then set the DisplayStyingFortmat to the TimeSpanPicker.

<telerikInput:RadTimeSpanPicker PlaceholderTemplate="{StaticResource placeholderTemplate}"
                                DisplayStringFormat="hh\:mm"
                                DisplayTemplate="{StaticResource displayTemplate}">
</telerikInput:RadTimeSpanPicker>
As I mentioned, if the behavior on your side is different, please open a support ticket and attach a sample project/code to it.

Hakob
Top achievements
Rank 2
Iron
commented on 31 Aug 2022, 08:11 AM

Thank you so much.
Tags
TimeSpanPicker
Asked by
Hakob
Top achievements
Rank 2
Iron
Answers by
Didi
Telerik team
Share this question
or