|
-
Feb 3rd, 2010, 04:46 AM
#1
Thread Starter
Fanatic Member
-
Feb 3rd, 2010, 06:14 AM
#2
Re: Creating Navigation User Control
It can be quite complicated to allow a UserControl to accept controls (eg: behave as a parent control).
The easiest case is when you want your whole UserControl to be able to accept controls (just like a Panel). You can specify a Designer attribute for your UserControl class and tell it to use the ParentControlDesigner. That's all you need to do; the rest is done automatically.
However, this makes no sense for the control you are talking about, as obviously you want to be able to put a control in a specific panel, depending on which 'button' is selected. To do that, you must add the 'panels' (they can be actual Panels, or any other control that accepts controls) during design-time.
Basically you need to use a DesignerHost object and its CreateComponent method to create a new panel object, which will then be enabled for design-time (unlike adding the panel in the UserControl designer, in which case it will be part of the UserControl and not have design-time enabled).
It's not trivial but it can be done. For an example, see my WizardControl example. There's also other examples such as a VisualStudiosTabControl by ForumAccount I think. The idea is the same.
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|