Validation.HasError property

Did I miss something?

1- Style

<Style TargetType="{x:Type TextBox}"> <Style.Triggers> <DataTrigger Binding="{Binding Path=Validation.HasError}" Value="true"> <Setter Property="BorderBrush" Value="Blue" /> </DataTrigger> </Style.Triggers> <Setter Property="MinWidth" Value="160" /> <Setter Property="Margin" Value="0 7 0 0"/> </Style> 

2 - Viewmodel implements IDataErrorInfo 3- text field of view

  <TextBox x:Name="FirstName" Text="{Binding Person.FirstName, UpdateSourceTrigger=PropertyChanged, ValidatesOnDataErrors=true}"></TextBox> 

3 - I am using Caliburn MVVM

I encountered a BindingExpression path error: the "Validation" property was not found in the "object" "PersonWindowViewModel" (HashCode = 38783181). "BindingExpression: Path = Validation.HasError; DataItem = 'PersonWindowViewModel' (HashCode = 38783181); target element is" TextBox "(Name =" FirstName "); target property -" NoTarget "(type" Object ")" S

+6
wpf mvvm caliburn idataerrorinfo
source share
1 answer

Check out Beth Massey’s article on verification here

Basically, you used a DataTrigger where you just need a Trigger

So:

 <Style.Triggers> <Trigger Property="Validation.HasError" Value="true"> <Setter ... /> </Trigger> </Style.Triggers> 
+14
source share

All Articles