![](/img/trans.png)
[英]Can a DependencyProperty bound two times to a TwoWay binding?
[英]DependencyProperty with TwoWay Binding
我有一个高度定制的Edit控件,该控件继承了RichTextBox
。 我需要一种将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.
}
请帮忙。
use可以在Binding语句中使用UpdateSourceTrigger=Explicit
并获得对属性更新的控制权。
检查该线程
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.