title: Adding controls to a panel on a User Control in designer
body: <p>I have a specific requirement to create a user control with specific common functions.  To that control I also have the requirement to allow other developers to add controls in designer mode to make specific UI's. To do this I created a user control, adding (sample) label, and button.  I also added a panel to allow adding of addition controls in a specific area of the control.    </p>
  
  <p>I then made the made the class visible in designer mode by adding [Designer] markup and a [ControlDesigner].  This gives the desired effect to add a User control with some fixed content, and add more controls to the page.  The problem is that the panel can be moved by the user in design mode, and VisualStudio gets confused, creating a circular reference..    I must be missing something?  Can I turn off the resizing/positioning of the panel, even though I need design mode enabled?   </p>
  
  <p>NOTE: I also tried to just use a user control in design mode, but added controls keep disappearing behind the fixed controls on the User Control.</p>
  
  <p>Code and examples are below.. Any suggestion/fixes welcomed..</p>
  
  <p><a href="https://i.stack.imgur.com/dH3Hd.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/dH3Hd.png" alt=""></a></p>
  
  <p>Above is the visual of the user control with the panel</p>
  
  <p><a href="https://i.stack.imgur.com/IKnsV.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/IKnsV.png" alt="enter image description here"></a></p>
  
  <p>Above is a form including the User control, and adding a custom button to the panel..  Note the panel drag is enable, if touched, a circular reference gets created in the form.designer.cs file, and the project becomes unstable.</p>
  
  <p>Finally below is the class for User Control</p>
  
  <pre><code>using System;
  using System.Collections.Generic;
  using System.ComponentModel;
  using System.ComponentModel.Design;
  using System.Drawing;
  using System.Data;
  using System.Linq;
  using System.Text;
  using System.Threading.Tasks;
  using System.Windows.Forms;
  using System.Diagnostics;
  
  using System.Windows.Forms.Design;
  
  namespace wfcLib
  {
  
      [DesignerAttribute(typeof(MyControlDesigner))]
      [Designer("System.Windows.Forms.Design.ParentControlDesigner, System.Design", typeof(IDesigner))]
      public partial class ucInput : UserControl
      {
  
          [DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
          public Panel InternalPanel
          {
              get { return pnlContent; }
              set { pnlContent = value; }
          }
          public ucInput()
          {
              InitializeComponent();
  
          }
  
      }
      [System.Security.Permissions.PermissionSet(System.Security.Permissions.SecurityAction.Demand, Name = "FullTrust")]
      public class MyControlDesigner : System.Windows.Forms.Design.ControlDesigner
      {
          public override void Initialize(IComponent c)
          {
              base.Initialize(c);
              ucInput ctl = (ucInput)c;
              EnableDesignMode(ctl.InternalPanel, "InternalPanel");
          }
      }
  }
  </code></pre>