[英]DependencyProperty with TwoWay Binding
I have a highly customized Edit control which inherits RichTextBox
. 我有一个高度定制的Edit控件,该控件继承了
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. 我需要一种将
Value
绑定到此控件的方法,所以我注册了一个新的DependencyProperty
,但是我很难像我需要的那样对其进行编码。
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. 请帮忙。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.