Maybe I am not using ValidationRule
correctly, if so, please show me the correct way.
Currently, I have implemented a class WarningForUncheckRule
inherited from ValidationRule
, and bind it to a binding.
<cc:StarCheckBox>
<cc:StarCheckBox.IsChecked>
<Binding>
<Binding.Path>IsFavorate</Binding.Path>
<Binding.ValidationRules>
<vm:WarningForUncheckRule />
</Binding.ValidationRules>
<Binding.Mode>TwoWay</Binding.Mode>
</Binding>
</cc:StarCheckBox.IsChecked>
</cc:StarCheckBox>
I implement the code and return false
as result (for test purpose here):
public class WarningForUncheckRule : ValidationRule
{
public override ValidationResult Validate(object value,
CultureInfo cultureInfo)
{
return new ValidationResult(false, null);
}
}
My question is if I return false
here, there is only the error UI showing with error message, but the UI status is still changed.
Is it possible to use false
ValidateResult to prevent the UI from being update?
If no, is there other way in binding to accomplish this?