|
I have changed the control to a TextBox thus simplifying the issue by using standard out of the box controls. I would expect a red outline to be displayed. I should note that I am using WPF. I have read: http://drc.ideablade.com/devforce-2012/bin/view/Documentation/cocktail-validation - http://drc.ideablade.com/devforce-2012/bin/view/Documentation/cocktail-validation and http://drc.ideablade.com/devforce-2012/bin/view/Documentation/verification-ui - http://drc.ideablade.com/devforce-2012/bin/view/Documentation/verification-ui (this one seems to hint at more code required for WPF to get this to work) and the code sample at: http://drc.ideablade.com/devforce-2012/bin/view/Documentation/code-sample-validation-wpf - http://drc.ideablade.com/devforce-2012/bin/view/Documentation/code-sample-validation-wpf My binding appears correct: <TextBox Text="{Binding ReportedBy, Mode=TwoWay, ValidatesOnDataErrors=True, NotifyOnValidationError=true}"/> In the model I have tried: /// <summary>Gets or sets the person who reported the incident. </summary> [DataMember] [Required] public string ReportedBy { get; set; }
and even added: /// <summary>Gets or sets the person who reported the incident. </summary> [DataMember] [Required] [IdeaBlade.Validation.RequiredValueVerifier(ErrorMessageResourceName = "ReportedBy")] public string ReportedBy { get; set; }
If I attempt save the record it will display a validation error dialog listing the fields in question that are at fault, but still no difference to the TextBox I have also added the custom style as recommended in the sample: <Style TargetType="{x:Type TextBox}"> <Setter Property="Validation.ErrorTemplate"> <Setter.Value> <ControlTemplate> <DockPanel> <TextBlock Foreground="Red" FontSize="20">!</TextBlock> <AdornedElementPlaceholder/> </DockPanel> </ControlTemplate> </Setter.Value> </Setter> <Style.Triggers> <Trigger Property="Validation.HasError" Value="true"> <Setter Property="ToolTip" Value="{Binding RelativeSource={RelativeSource Self}, Path=(Validation.Errors)[0].ErrorContent}"/> </Trigger> </Style.Triggers> </Style> <Setter Property="Validation.ErrorTemplate"> <Setter.Value> <ControlTemplate> <DockPanel> <TextBlock Foreground="Red" FontSize="20">!</TextBlock> <AdornedElementPlaceholder/> </DockPanel> </ControlTemplate> </Setter.Value> </Setter> <Style.Triggers> <Trigger Property="Validation.HasError" Value="true"> <Setter Property="ToolTip" Value="{Binding RelativeSource={RelativeSource Self}, Path=(Validation.Errors)[0].ErrorContent}"/> </Trigger> </Style.Triggers> </Style>
|