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;
|
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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -40,6 +40,7 @@
|
|||||||
<Setter Property="ScrollViewer.PanningMode" Value="VerticalFirst"/>
|
<Setter Property="ScrollViewer.PanningMode" Value="VerticalFirst"/>
|
||||||
<Setter Property="Stylus.IsFlicksEnabled" Value="False"/>
|
<Setter Property="Stylus.IsFlicksEnabled" Value="False"/>
|
||||||
<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="TextBox">
|
<ControlTemplate TargetType="TextBox">
|
||||||
@@ -255,6 +256,7 @@
|
|||||||
</ControlTemplate>
|
</ControlTemplate>
|
||||||
|
|
||||||
<Style x:Key="TextBoxPlusBaseStyle" BasedOn="{StaticResource TextBoxExtendBaseStyle}" TargetType="hc:TextBox">
|
<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}"/>
|
<Setter Property="Template" Value="{StaticResource TextBoxPlusTopTemplate}"/>
|
||||||
<Style.Triggers>
|
<Style.Triggers>
|
||||||
<Trigger Property="hc:InfoElement.TitlePlacement" Value="Left">
|
<Trigger Property="hc:InfoElement.TitlePlacement" Value="Left">
|
||||||
|
|||||||
Reference in new issue
Block a user