hc:TextBox support for Validation
This commit is contained in:
1 parent
17a54ef7ea
commit
fcf3f9b72f
2 files changed
+18
-3
No files matched your search
@@ -112,9 +112,22 @@ namespace HandyControl.Controls
|
||||
}
|
||||
}
|
||||
|
||||
IsError = !result.Data;
|
||||
ErrorStr = result.Message;
|
||||
return result.Data;
|
||||
var isError = !result.Data;
|
||||
if (isError)
|
||||
{
|
||||
SetCurrentValue(IsErrorProperty, true);
|
||||
SetCurrentValue(ErrorStrProperty, result.Message);
|
||||
}
|
||||
else
|
||||
{
|
||||
isError = Validation.GetHasError(this);
|
||||
if (isError)
|
||||
{
|
||||
SetCurrentValue(ErrorStrProperty, Validation.GetErrors(this)[0].ErrorContent);
|
||||
}
|
||||
}
|
||||
|
||||
return !isError;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -40,6 +40,7 @@
|
||||
<Setter Property="ScrollViewer.PanningMode" Value="VerticalFirst"/>
|
||||
<Setter Property="Stylus.IsFlicksEnabled" Value="False"/>
|
||||
<Setter Property="VerticalContentAlignment" Value="Center"/>
|
||||
<Setter Property="Validation.ErrorTemplate" Value="{x:Null}"/>
|
||||
<Setter Property="Template">
|
||||
<Setter.Value>
|
||||
<ControlTemplate TargetType="TextBox">
|
||||
@@ -255,6 +256,7 @@
|
||||
</ControlTemplate>
|
||||
|
||||
<Style x:Key="TextBoxPlusBaseStyle" BasedOn="{StaticResource TextBoxExtendBaseStyle}" TargetType="hc:TextBox">
|
||||
<Setter Property="IsError" Value="{Binding Path=(Validation.HasError),RelativeSource={RelativeSource Self}}"/>
|
||||
<Setter Property="Template" Value="{StaticResource TextBoxPlusTopTemplate}"/>
|
||||
<Style.Triggers>
|
||||
<Trigger Property="hc:InfoElement.TitlePlacement" Value="Left">
|
||||
|
||||
Reference in new issue
Block a user