ValidationRule bind two values
-
Hi folks! Can anyone please help me with this: I have two values (one manual input and one from a database) and I need to compare them/ validate them via ValidationRules and show errors if they do not match. LOGIC: V1 == V2 => OK V1 != V2 => NOK, Error
<TextBlock>
<TextBlock.Text>
<Binding ...>
<Binding.ValidationRules>
<localValidation:ValidateIt V1={Binding Path=...} V2={Binding Path=}/>
</Binding.ValidationRules/>
<TextBlock.Text/>
</TextBlock>where
public class ValidateIt : ValidationRule
public int V1 {get;set;}
public int V2 {get;set;}Unfortunately it tells me, that V1 and V2 cannot be bound due to the fact, that these are no DependencyProperties. I'm stuck... Thanks in advance, eza
-
Hi folks! Can anyone please help me with this: I have two values (one manual input and one from a database) and I need to compare them/ validate them via ValidationRules and show errors if they do not match. LOGIC: V1 == V2 => OK V1 != V2 => NOK, Error
<TextBlock>
<TextBlock.Text>
<Binding ...>
<Binding.ValidationRules>
<localValidation:ValidateIt V1={Binding Path=...} V2={Binding Path=}/>
</Binding.ValidationRules/>
<TextBlock.Text/>
</TextBlock>where
public class ValidateIt : ValidationRule
public int V1 {get;set;}
public int V2 {get;set;}Unfortunately it tells me, that V1 and V2 cannot be bound due to the fact, that these are no DependencyProperties. I'm stuck... Thanks in advance, eza
They don't need to be DependencyPropety's to be bound. There's a lightweight way of achieving what you want using POCO's. If you take a look at my sample here[^], you'll see that I'm handling the validation based on a ViewModel, which is totally none-DP based.
"WPF has many lovers. It's a veritable porn star!" - Josh Smith
As Braveheart once said, "You can take our freedom but you'll never take our Hobnobs!" - Martin Hughes.