2

我想在 wpf 中获取控件属性的绑定(如 setBinding(Dp,Binding))。之后,我想为那个添加更多绑定,比如在代码中添加validationRule(而不是在xaml中)。任何人都可以用示例代码回复。

4

1 回答 1

7
BindingExpression bindingExpression = c_textBox1.GetBindingExpression(TextBox.TextProperty);
    Binding parentBinding = bindingExpression.ParentBinding;

    //make new MultiBinding expression and add parentBinding into it.
     MultiBinding bindingList = new MultiBInding();
     bindingList.Bindings.Add(parentBinding);
    c_textBox1.SetBinding(TextBox.TextProperty, bindingList);
于 2012-09-02T16:42:29.743 回答