All the controls missing in WPF. Over 1 million downloads.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

32 lines
987 B

using System;
using System.Windows.Data;
using System.Globalization;
namespace Microsoft.Windows.Controls.PropertyGrid.Editors
{
public class TimeSpanEditor : DateTimeUpDownEditor
{
private sealed class TimeSpanConverter : IValueConverter
{
object IValueConverter.Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
return DateTime.Today + (TimeSpan)value;
}
object IValueConverter.ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
return ((DateTime)value).TimeOfDay;
}
}
protected override void SetControlProperties()
{
Editor.Format = DateTimeFormat.LongTime;
}
protected override IValueConverter CreateValueConverter()
{
return new TimeSpanConverter();
}
}
}