views:

69

answers:

1

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>
+1  A: 

You could use Josh Smith's virtual branch approach.

HTH,
Kent

Kent Boogaart
I will give this a try.
Taylor Leese
One thing I'm getting hung up on in the article is how to update the DataContext of my control to <Binding Mode="OneWayToSource" Path="DataContext" Source="{StaticResource DataContextBridge}"/> because I already have DataContext="{Binding RelativeSource={RelativeSource self}}". Any ideas?
Taylor Leese
I asked another related question here: http://stackoverflow.com/questions/1864432/wpf-how-to-set-datacontext-on-virtual-branch-of-logical-tree
Taylor Leese