Validation in WPF TimeSpanEdit
Restrict within min and max value
The Value
of the TimeSpanEdit
can be restricted within the maximum and minimum limits. Once the percent value has reached the maximum or minimum value , the value does not exceed the limit. We can change the maximum and minimum limits by using the MinValue property and MaxValue property.
Another way,
By using the keyboard, you can not enter the value above or below the predefined maximized or minimized value.
-
MaxValue - The MaxValue property is the maximum value that can be set for the
TimeSpanEdit
control. -
MinValue - The MinValue property is the minimum value that can be set for the
TimeSpanEdit
control.
<syncfusion:TimeSpanEdit Value="10.2:25:52" Width="150" Height="30" MinValue="2.0:0:0" MaxValue="31.0:0:0"/>
timespan.MinValue= new TimeSpan(2,0,0,0);
timespan.MaxValue = new TimeSpan(31, 0, 0, 0);
Min value
Max value
Read only value
The TimeSpanEdit
cannot allow the user input, edits when IsReadOnly property is sets to true
. The user can still select text and display the cursor on the TimeSpanEdit
by setting the IsReadOnlyCaretVisible property to true
. However, value can be changed programmatically in readonly mode.
<syncfusion:TimeSpanEdit x:Name="timespanedit" IsReadOnly="True" Value="1.2:3:4" IsReadOnlyCaretVisible="True"/>
TimeSpanEdit timespanedit = new TimeSpanEdit();
timespanedit.Value = new TimeSpan(3, 5, 4, 3);
timespanedit.IsReadOnly = true;
timespanedit.IsReadOnlyCaretVisible = true;