I'm designing a custom Wizard control via a UserControl. I am using a sub-control in it called WizardPageControl
which is derived from TabControl
to host the wizard pages and need this editable in the designed view of the final Wizard
User Control. I have achieved this via the code below:
[Designer(typeof(WizardDesigner))]
public partial class Wizard : BaseUserControl
{
[Browsable(false)]
[DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
public WizardPageControl WizardPageControlArea
{
get { return wizardPageControl; }
}
public Wizard()
{
InitializeComponent();
}
}
internal class WizardDesigner : ParentControlDesigner
{
public override void Initialize(System.ComponentModel.IComponent component)
{
base.Initialize(component);
var uc = (Wizard)component;
EnableDesignMode(uc.WizardPageControlArea, "WizardPageControlArea");
}
}
If I construct a simple Wizard
UserControl with A Label Docked to the Top, another Label docked to the bottom and a WizardPageControl
named wizardPageControl
set to Dock Fill, I get this when I build and place the control on a form:
All good. Except when I close and re-open the form, I get this (the move handle and outlined box is wizardPageControl
):
Basically, wizardPageControl
Dock-Fill has expanded to fill the whole form, not between the top and bottom label docks. So, simple: put it in a panel, right? No dice. As soon as I put it in any kind of container, VS crashes when trying to add the Wizard
UserControl to any form. I'm guessing that this is because wizardPageControl
(and its corresponding public Property WizardPageControlArea
) is no longer a direct child control of the form, rather a child control of another container.
I've read through the MS documentation for EnableDesignMode
and also INestedContainer
but as ever found it about as useful as an umbrella in a typhoon.
Any help would be gratefully received.