Telerik UI for Windows Phone by Progress

RadTimeSpanPicker exposes the following events:

  • ValueChanging - fired when the value of the control is about to be changed. Can be cancelled.
  • ValueChanged - fired when the value of the control has changed.
  • PopupOpening - fired when the selector popup of the control is about to be opened.
  • PopupOpened - fired when the selector popup of the control has been opened.
  • UpdatingValueString - fired when the ValueString property is about to be updated upon value change. Can be used to override the default the format of the value string.

Using the UpdatingValueString event

Upon value selection the ValueString property is udpated with a string representing the selected value formatted by using the default value format string defined on the control. After the value string is composed the UpdatingValueString is fired providing the possibility to redefine the Value String. The following C# code snippet demonstrates how a custom formatting can be applied:

CopyC#
private void radTimeSpanPicker_UpdatingValueString(object sender, ValueStringUpdateEventArgs e)
{
    RadTimeSpanPicker timeSpanPicker = sender as RadTimeSpanPicker;
    if (timeSpanPicker.Value.HasValue)
    {
        e.ValueString = string.Format("{0:D2} days, {1:D2} hours, {2:D2} minutes, {3:D2} seconds",
            timeSpanPicker.Value.Value.Days,
            timeSpanPicker.Value.Value.Hours,
            timeSpanPicker.Value.Value.Minutes, 
            timeSpanPicker.Value.Value.Seconds);
    }
}

This code will produce the following custom value string upon value selection:

Time Span Custom Value String