Skip to main content

How to: Reuse the RichEditControl

The RichEditControl’s inner template is disposed of when you close the window with RichEditControl. As a result, the further use of the RichEditControl is impossible. The following code example shows how to retain the RichEditControl’s inner template to reuse it. In the RichEditControl.Loaded event handler, obtain the DockLayoutManager in the RichEditControl’s template and set its DockLayoutManager.DisposeOnWindowClosing property to false, as shown in the code snippet below:

private void RichEditControl_Loaded(object sender, RoutedEventArgs e)
   {
       RichEditControl control = sender as RichEditControl;
       DockLayoutManager manager = control.Template.FindName("PART_DockLayoutManager", control) as DockLayoutManager;
       if (manager != null)
           manager.DisposeOnWindowClosing = false;
   }