Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I suspect that since instances of <code>DependencyPropertyDescriptor</code> are likely to be cached at application level, the references to ValueChanged delegate (the anonymous delegate in <code>OnInitialized</code> method) might leak instances of the <code>BindableRichTextBox</code>. </p> <p>In the code shown there isn't, indeed, any call to <code>DependencyPropertyDescriptor.RemoveValueChanged</code> to remove the handler. </p> <p>You might consider using the <code>DependencyProperty.Register</code> overload, which supports a <code>PropertyMetadata</code> parameter; this allows you to specify a proper PropertyChangedCallback for the property (see <a href="http://msdn.microsoft.com/en-us/library/cc903933(v=VS.95).aspx#metadata" rel="nofollow">http://msdn.microsoft.com/en-us/library/cc903933(v=VS.95).aspx#metadata</a>):</p> <pre><code>public static readonly DependencyProperty DocumentProperty = DependencyProperty.Register("Document", typeof(FlowDocument), typeof(BindableRichTextBox), new PropertyMetadata(null, new PropertyChangedCallback(OnDocumentChanged) ) ); public static void OnDocumentChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) { ((BindableRichTextBox)d).SetBaseDocument((FlowDocument)e.NewValue); } public new FlowDocument Document { get { return (FlowDocument)GetValue(DocumentProperty); } set { SetValue(DocumentProperty, value); } } private SetBaseDocument(FlowDocument document) { base.Document = (FlowDocument)GetValue(DocumentProperty); } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload