开发者

WPF - Workaround for ValidationRule not being a DependencyObject

开发者 https://www.devze.com 2022-12-13 15:46 出处:网络
What is the best solution for not being able to use data binding on a ValidationRule property since ValiationRule is not 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 b开发者_运维知识库e 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>


You could use Josh Smith's virtual branch approach.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号