【发布时间】:2011-01-08 04:09:06
【问题描述】:
我有一个高度自定义的编辑控件,它继承了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.
}
请帮忙。
【问题讨论】:
标签: c# .net wpf data-binding dependency-properties