[英]How to change TextEdit border color during user input validation
如何在使用DevExpress進行用戶輸入驗證期間更改WPF表單中的TextEdit邊框顏色
我的表格中有項目:
<dxe:TextEdit x:Name="txtTextEdit"
Text="{Binding FilterField,
UpdateSourceTrigger=PropertyChanged}"
ValidateOnTextInput="False"
Validate="txtValidate"/>
還創建了void以驗證此字段:
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";
}
以及如何更改邊框顏色而不顯示錯誤?
<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
是屬性。 您需要定義適當的綁定。 它的數據類型應該是System.Windows.Controls
的Brush
。 您需要使用此庫。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.