开发者

DependencyProperty with TwoWay Binding

开发者 https://www.devze.com 2022-12-17 14:37 出处:网络
I have a highly customized Edit control which inher开发者_开发知识库its RichTextBox. I needed a way to bind a Value to this control, so I registered a new DependencyProperty, but I have trouble to cod

I have a highly customized Edit control which inher开发者_开发知识库its RichTextBox. I needed a way to bind a Value to this control, so I registered a new DependencyProperty, but I have trouble to code it like I need.

public static readonly DependencyProperty ValueProperty =
            DependencyProperty.Register("Value", typeof(string), typeof(XliffRichCellEditor),
            new PropertyMetadata(new PropertyChangedCallback(XliffRichCellEditor.OnValuePropertyChanged)));
public String Value
{
    get { return (String)this.GetValue(ValueProperty); }
    set { this.SetValue(ValueProperty, value); }
}

private static void OnValuePropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
{
    // Need to change Document in  RichTextBox when Binding Source is changed
    // But also ignore if the change comes from RichTextBox which is only updating
    // the DependencyProperty. In this case Binding Source should be updated.
}

Please help.


use can use UpdateSourceTrigger=Explicit in your Binding statement and get the control of property updation in your hand.

Check this Thread

0

精彩评论

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

关注公众号