This question is locked. New answers and comments are not allowed.
Hi
I am trying set validation state with custom Behavior:
My behaviour is:
My xaml is:
To textbox1 I set validationState in codebehind, textbox2 has set throw behavior. But result is different, see screenshots.
No error messages showed, but focus state is correct.
I am trying set validation state with custom Behavior:
My behaviour is:
public class ValidationBehavior : Behavior<RadTextBox> { public String ValidationError { get { return (String)GetValue(ValidationErrorProperty); } set { SetValue(ValidationErrorProperty, value); } } // Using a DependencyProperty as the backing store for ValidationError. This enables animation, styling, binding, etc... public static readonly DependencyProperty ValidationErrorProperty = DependencyProperty.Register("ValidationError", typeof(String), typeof(ValidationBehavior), new PropertyMetadata(null, validationErrorChanged)); private static void validationErrorChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) { if ((d as ValidationBehavior).AssociatedObject != null) { (d as ValidationBehavior).UpdateValidationError(); } } protected override void OnAttached() { base.OnAttached(); UpdateValidationError(); } void UpdateValidationError() { if (ValidationError == null) AssociatedObject.ChangeValidationState(ValidationState.NotValidated, ""); else AssociatedObject.ChangeValidationState(ValidationState.Invalid, ValidationError); } }My xaml is:
<StackPanel x:Name="ContentPanel" Grid.Row="1" Margin="12,0,12,0"> <telerikPrimitives:RadTextBox x:Name="text1" /> <telerikPrimitives:RadTextBox x:Name="text2"> <i:Interaction.Behaviors> <local:ValidationBehavior ValidationError="Error" /> </i:Interaction.Behaviors> </telerikPrimitives:RadTextBox> </StackPanel>To textbox1 I set validationState in codebehind, textbox2 has set throw behavior. But result is different, see screenshots.
No error messages showed, but focus state is correct.