![](/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.