Wpf TimeSpanUpDown in seconds

I am using the Extended WPF Toolkit.

https://wpftoolkit.codeplex.com/wikipage?title=TimeSpanUpDown

When I click the arrow, the default value of the clock increases.

Is there a way to make it first increase the number of seconds as the default behavior?

+4
source share
2 answers

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;
    }

}

Thus, if you press the arrow, you will increase only seconds.

+1
source

CurrentDateTimePart="Second" TimeSpanUpDown xaml, . DateTimePart , - , .

+1

All Articles