开发者

DependencyProperty with TwoWay Binding

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜