Reputation: 219
How to change TextEdit border color in WPF form during user input validation using DevExpress
I have item in my form:
<dxe:TextEdit x:Name="txtTextEdit"
Text="{Binding FilterField,
UpdateSourceTrigger=PropertyChanged}"
ValidateOnTextInput="False"
Validate="txtValidate"/>
Also created void to validate this field:
private void txtValidate(object sender, DevExpress.Xpf.Editors.ValidationEventArgs e)
{
if (e.Value == null) return;
if (e.Value.ToString().Length > 4) return;
e.IsValid = false;
e.ErrorType = DevExpress.XtraEditors.DXErrorProvider.ErrorType.Warning;
e.ErrorContent = "Enter more than 4 symbols";
}
And how to change border color instead of showing error?
Upvotes: 0
Views: 1144
Reputation: 4000
<Border BorderBrush="{Binding MyBorderBrush}">
<dxe:TextEdit x:Name="txtTextEdit"
Text="{Binding FilterField,
UpdateSourceTrigger=PropertyChanged}"
ValidateOnTextInput="False"
Validate="txtValidate"/>
</Border>
and this in the method,
e.IsValid = false;
e.ErrorType = DevExpress.XtraEditors.DXErrorProvider.ErrorType.Warning;
e.ErrorContent = "Enter more than 4 symbols";
MyBorderBrush = Brushes.Red;
MyBorderBrush
is property. You need to define proper binding. Its datatype should be of Brush
which is from System.Windows.Controls
. You need to use this library.
Upvotes: 1