如何使用DevExpress
在用户输入验证期间更改WPF表单中的TextEdit边框颜色我的表格中有项目:
<dxe:TextEdit x:Name="txtTextEdit"
Text="{Binding FilterField,
UpdateSourceTrigger=PropertyChanged}"
ValidateOnTextInput="False"
Validate="txtValidate"/>
还创建了无效以验证此字段:
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";
}
如何更改边框颜色而不是显示错误?
答案 0 :(得分:1)
<Border BorderBrush="{Binding MyBorderBrush}">
<dxe:TextEdit x:Name="txtTextEdit"
Text="{Binding FilterField,
UpdateSourceTrigger=PropertyChanged}"
ValidateOnTextInput="False"
Validate="txtValidate"/>
</Border>
这个方法,
e.IsValid = false;
e.ErrorType = DevExpress.XtraEditors.DXErrorProvider.ErrorType.Warning;
e.ErrorContent = "Enter more than 4 symbols";
MyBorderBrush = Brushes.Red;
MyBorderBrush
是属性。您需要定义正确的绑定。其数据类型应为Brush
,来自System.Windows.Controls
。您需要使用此库。