title: Open referenced control in a new window
body: <h2>Issue</h2>
  
  <p>I want to load a referenced control from the main window into a new window. The referenced control is already child of the main window, causing the following exception when attempting to render the new window:</p>
  
  <blockquote>
    <p>System.ArgumentException was unhandled:</p>
    
    <p>Must disconnect specified child from current parent Visual before attaching to new parent Visual.</p>
  </blockquote>
  
  <p>I do not want to disconnect it from the main window and I also cannot create a new instance of the control since I do not know how it's instantiated or what members are applied.</p>
  
  <h2>Background</h2>
  
  <p>I'm developing an application that allows developers to extend the application with additional views of configuration options. The container of these views may turn out to be too small for large view extensions (imagine a scheduling control for agendas as example), so I wish to provide the user with the ability to open the extended view in a new window. </p>
  
  <h2>Code</h2>
  
  <p>So far I've created a behavior to attach to Hyperlinks that opens a new window with the referenced control upon the <code>Click</code> event. The following code is the most basic implementation to demonstrate my intention:</p>
  
  <pre><code>public class ExpandViewBehavior : Behavior&lt;Hyperlink&gt;
  {
      public static DependencyProperty ViewProperty = DependencyProperty.Register("View", typeof(object), typeof(ExpandViewBehavior));
  
      public object View
      {
          get { return GetValue(ViewProperty); }
          set { SetValue(ViewProperty, value); }
      }
  
      protected override void OnAttached()
      {
          this.AssociatedObject.Click += AssociatedObject_Click;
      }
  
      void AssociatedObject_Click(object sender, RoutedEventArgs e)
      {
          if (View != null)
          {
              var window = new Window()
              {
                  Content = View
              };
              window.Show();
          }
      }
  }
  </code></pre>
  
  <p>Attached to a <code>Hyperlink</code> in the main window, referencing a simple <code>TextBox</code> to load in the new window. Where <code>i</code> is the <code>System.Windows.Interactivity</code> namespace and <code>local</code> my project namespace.</p>
  
  <pre><code>xmlns:local="clr-namespace:WpfApplication"
  xmlns:i="http://schemas.microsoft.com/expression/2010/interactivity"
  
  ...
  
  &lt;StackPanel&gt;
      &lt;TextBlock&gt;
          &lt;Hyperlink&gt;
              &lt;i:Interaction.Behaviors&gt;
                  &lt;local:ExpandViewBehavior
                      View="{Binding Source={x:Reference SomeControl}}" /&gt;
              &lt;/i:Interaction.Behaviors&gt;
              &lt;TextBlock
                  Text="(Open in new window)" /&gt;
          &lt;/Hyperlink&gt;
      &lt;/TextBlock&gt;
      &lt;TextBox
          x:Name="SomeControl" /&gt;
  &lt;/StackPanel&gt;
  </code></pre>
  
  <p>My question is, is there is a way to load the referenced control without disconnecting it from the main window?</p>