mirror of
https://gitee.com/handyorg/HandyControl.git
synced 2024-12-02 20:07:56 +08:00
hc:DatePicker support for Validation
This commit is contained in:
parent
ac8b5561a5
commit
13d9404848
@ -188,7 +188,7 @@ namespace HandyControl.Controls
|
|||||||
var isError = !result.Data;
|
var isError = !result.Data;
|
||||||
if (isError)
|
if (isError)
|
||||||
{
|
{
|
||||||
SetCurrentValue(IsErrorProperty, true);
|
SetCurrentValue(IsErrorProperty, ValueBoxes.TrueBox);
|
||||||
SetCurrentValue(ErrorStrProperty, result.Message);
|
SetCurrentValue(ErrorStrProperty, result.Message);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -360,7 +360,7 @@ namespace HandyControl.Controls
|
|||||||
var isError = !result.Data;
|
var isError = !result.Data;
|
||||||
if (isError)
|
if (isError)
|
||||||
{
|
{
|
||||||
SetCurrentValue(IsErrorProperty, true);
|
SetCurrentValue(IsErrorProperty, ValueBoxes.TrueBox);
|
||||||
SetCurrentValue(ErrorStrProperty, result.Message);
|
SetCurrentValue(ErrorStrProperty, result.Message);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -153,9 +153,21 @@ namespace HandyControl.Controls
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
IsError = !result.Data;
|
var isError = !result.Data;
|
||||||
ErrorStr = result.Message;
|
if (isError)
|
||||||
return result.Data;
|
{
|
||||||
|
SetCurrentValue(IsErrorProperty, true);
|
||||||
|
SetCurrentValue(ErrorStrProperty, result.Message);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
isError = Validation.GetHasError(this);
|
||||||
|
if (isError)
|
||||||
|
{
|
||||||
|
SetCurrentValue(ErrorStrProperty, Validation.GetErrors(this)[0].ErrorContent);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return !isError;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -120,7 +120,7 @@ namespace HandyControl.Controls
|
|||||||
Value = 0;
|
Value = 0;
|
||||||
|
|
||||||
SetCurrentValue(ErrorStrProperty, string.Empty);
|
SetCurrentValue(ErrorStrProperty, string.Empty);
|
||||||
SetCurrentValue(IsErrorProperty, false);
|
SetCurrentValue(IsErrorProperty, ValueBoxes.FalseBox);
|
||||||
}
|
}
|
||||||
else if (double.TryParse(_textBox.Text, out var value))
|
else if (double.TryParse(_textBox.Text, out var value))
|
||||||
{
|
{
|
||||||
@ -129,7 +129,7 @@ namespace HandyControl.Controls
|
|||||||
if (Validation.GetHasError(this))
|
if (Validation.GetHasError(this))
|
||||||
{
|
{
|
||||||
SetCurrentValue(ErrorStrProperty, Validation.GetErrors(this)[0].ErrorContent);
|
SetCurrentValue(ErrorStrProperty, Validation.GetErrors(this)[0].ErrorContent);
|
||||||
SetCurrentValue(IsErrorProperty, true);
|
SetCurrentValue(IsErrorProperty, ValueBoxes.TrueBox);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -513,7 +513,7 @@ namespace HandyControl.Controls
|
|||||||
}
|
}
|
||||||
|
|
||||||
SetCurrentValue(ErrorStrProperty, result.Message);
|
SetCurrentValue(ErrorStrProperty, result.Message);
|
||||||
SetCurrentValue(IsErrorProperty, !result.Data);
|
SetCurrentValue(IsErrorProperty, ValueBoxes.BooleanBox(!result.Data));
|
||||||
return result.Data;
|
return result.Data;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -115,7 +115,7 @@ namespace HandyControl.Controls
|
|||||||
var isError = !result.Data;
|
var isError = !result.Data;
|
||||||
if (isError)
|
if (isError)
|
||||||
{
|
{
|
||||||
SetCurrentValue(IsErrorProperty, true);
|
SetCurrentValue(IsErrorProperty, ValueBoxes.TrueBox);
|
||||||
SetCurrentValue(ErrorStrProperty, result.Message);
|
SetCurrentValue(ErrorStrProperty, result.Message);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -34,6 +34,7 @@
|
|||||||
<Setter Property="Padding" Value="{StaticResource DefaultInputPadding}"/>
|
<Setter Property="Padding" Value="{StaticResource DefaultInputPadding}"/>
|
||||||
<Setter Property="BorderThickness" Value="1"/>
|
<Setter Property="BorderThickness" Value="1"/>
|
||||||
<Setter Property="VerticalContentAlignment" Value="Center"/>
|
<Setter Property="VerticalContentAlignment" Value="Center"/>
|
||||||
|
<Setter Property="Validation.ErrorTemplate" Value="{x:Null}"/>
|
||||||
<Setter Property="Template">
|
<Setter Property="Template">
|
||||||
<Setter.Value>
|
<Setter.Value>
|
||||||
<ControlTemplate TargetType="DatePicker">
|
<ControlTemplate TargetType="DatePicker">
|
||||||
@ -343,6 +344,7 @@
|
|||||||
</ControlTemplate>
|
</ControlTemplate>
|
||||||
|
|
||||||
<Style x:Key="DatePickerPlusBaseStyle" BasedOn="{StaticResource DatePickerExtendBaseStyle}" TargetType="hc:DatePicker">
|
<Style x:Key="DatePickerPlusBaseStyle" BasedOn="{StaticResource DatePickerExtendBaseStyle}" TargetType="hc:DatePicker">
|
||||||
|
<Setter Property="IsError" Value="{Binding Path=(Validation.HasError),RelativeSource={RelativeSource Self}}"/>
|
||||||
<Setter Property="CaretBrush" Value="{DynamicResource PrimaryTextBrush}"/>
|
<Setter Property="CaretBrush" Value="{DynamicResource PrimaryTextBrush}"/>
|
||||||
<Setter Property="Template" Value="{StaticResource DatePickerPlusTopTemplate}"/>
|
<Setter Property="Template" Value="{StaticResource DatePickerPlusTopTemplate}"/>
|
||||||
<Style.Triggers>
|
<Style.Triggers>
|
||||||
|
Loading…
Reference in New Issue
Block a user