我有一个自定义的RichTextBox,其中Text属性包含纯文本文本,而Dependency属性'Rtf'包含文本为rtf . 当我通过拖放移动文本时,我想在删除后更新此Rtf属性 . 例如,当我将文本从RichTextBox移动到TextBox时,我在TextBox中成功删除后查找事件 . 为此目的有什么事吗?

简单的例子:

public class RichTextBox : System.Windows.Controls.RichTextBox
{
    static RichTextBox()
    {
        DefaultStyleKeyProperty.OverrideMetadata(typeof(RichTextBox), new FrameworkPropertyMetadata(typeof(RichTextBox)));
    }

 public string Rtf
    {
        get { return (string)GetValue(RtfProperty); }
        set
        {
            SetValue(RtfProperty, value);
        }
    }

    // Using a DependencyProperty as the backing store for Text.  This enables animation, styling, binding, etc...
    public static readonly DependencyProperty RtfProperty =
        DependencyProperty.Register("Rtf", typeof(string), typeof(RichTextBox), new FrameworkPropertyMetadata(string.Empty, FrameworkPropertyMetadataOptions.BindsTwoWayByDefault, OnRtfPropertyChanged));
}