Search code examples
c#winformscompact-framework

How to create a user container control in compact framework?


When we need to create a container control in "regular" framework, we simply add

using System.ComponentModel;

and an attribute to the control class:

[Designer("System.Windows.Forms.Design.ParentControlDesigner, System.Design", 
           typeof(IDesigner))]
public partial class MyContainerControl : UserControl
....

However, in compact framework this seems to be impossible since the DesignerAttributes class does not exist.

I already have the user control, but I need it to act as a container in design time.
I've tried googling anything I could think of, but came up with nothing.
Is there any way to create a container user control except inheriting an existing container control?


Solution

  • The UserControl class inherits directly from ContainerControl which the same inheritance as Form. Oddly, Panel inherits from ScrollableControl (ContainerControls parent) so despite being a panel it isn't a Container.

    Anyway, it's not the inheritance that's the issue. The design time control is actually defined in a separate assembly compiled with the full framework to give you the attributes back (hopefully sharing the source between the two). It's really a completely separate control.

    See here