Taylor Leese
Taylor Leese

Reputation: 52292

WPF - Workaround for ValidationRule not being a DependencyObject

What is the best solution for not being able to use data binding on a ValidationRule property since ValiationRule is not a DependencyObject?

Below is an example of what I would like to do. I want to be able to validate the text in the TextBox against some other DependencyProperty.

<TextBox Name="myTextBox">
    <TextBox.Text>
        <Binding Path="MySource" UpdateSourceTrigger="PropertyChanged">
            <base:EqualsRule Target="{Binding MyTarget}" />
        </Binding>
    </TextBox.Text>
</TextBox>

Upvotes: 1

Views: 762

Answers (1)

Kent Boogaart
Kent Boogaart

Reputation: 178630

You could use Josh Smith's virtual branch approach.

Upvotes: 1

Related Questions