I'm using Extended WPF Toolkit.
https://wpftoolkit.codeplex.com/wikipage?title=TimeSpanUpDown
When I click the arrow, by default it increases the value of hours .
Is there a way to make it increase the seconds first as a default behavior ?
I would extend the WPF Toolkit TimeSpanUpDown control in this way:
public class TimeSpanUpDown : Xceed.Wpf.Toolkit.TimeSpanUpDown
{
protected override void OnIncrement()
{
if (Value.HasValue)
{
UpdateTimeSpan(1);
}
else
{
Value = DefaultValue ?? TimeSpan.Zero;
}
}
protected override void OnDecrement()
{
if (Value.HasValue)
{
UpdateTimeSpan(-1);
}
else
{
Value = DefaultValue ?? TimeSpan.Zero;
}
}
private void UpdateTimeSpan(int value)
{
TimeSpan timeSpan = (TimeSpan)Value;
timeSpan = timeSpan.Add(new TimeSpan(0, 0, 0, value, 0));
if (IsLowerThan(timeSpan, Minimum))
{
Value = Minimum;
return;
}
if (IsGreaterThan(timeSpan, Maximum))
{
Value = Maximum;
return;
}
Value = timeSpan;
}
}
In this way if you click the Arrow you increase just the seconds.
if you use the add the property CurrentDateTimePart="Second"
to the TimeSpanUpDown element in your xaml, you will get the desired effect. This simply sets the default DateTimePart
on first load, and the keyboard controls still work as expected.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With