Question

For a C# UserControl on Windows Mobile (though please answer if you know it for full Windows...it might work) how do you change what shows up in the Designer Properties window for one of the Control's public Properties. For example:

private Color blah = Color.Black;

public Color Blah
{
    get { return this.blah; }
    set { this.blah = value; }
}

This shows up for the control, but it's in the "Misc" category and has no description or default value. I've tried using the settings in System.ComponentModel like "DesignerCategory", such as:

[DesignerCategory("Custom")]

But says this is only valid for class declarations... could've sworn it was the System.ComponentModel items I used before...

Update:

@John said:

DesignerCatogy is used to say if the class is a form, component etc.

Try this:

[Category("Custom")]

Is there a particular namespace I need to use in order to get those? I've tried those exactly and the compiler doesn't recognize them.

In .NETCF all I seem to have available from System.ComponentModel is:

DataObject,
DataObjectMethod,
DefaultValue,
DesignerCategory,
DesignTimeVisible,
EditorBrowsable

The only one it doesn't scream at is EditorBrowsable

Was it helpful?

Solution

Is this of use to you? I am not into CF development, but it looks like you need to add some XML metadata to enable it:

http://blogs.msdn.com/bluecollar/archive/2007/02/08/adding-compact-framework-design-time-attributes-or-more-fun-with-textboxes.aspx

Interesting read.. Looks like a lot of design time support was stripped out of CF because you dont design them on the devices.. Which seems kinda weird to me.. Cant imagine using a handheld as a development rig!

Scroll down about half way for the good stuff ;)

OTHER TIPS

DesignerCatogy is used to say if the class is a form, component etc.

For full windows the attribute you want is:

[System.ComponentModel.Category("Custom")]

and for the description you can use [System.ComponentModel.Description("This is the description")]

to use both together

[System.ComponentModel.Category("Custom"),System.ComponentModel.Description("This is the description")]

However this is part of system.dll which may be different for windows mobile.

The article does not suggest that anyone is designing ON the device. However, when you create a Compact Framework project, the compact framework (for your desktop PC) is used to handle design time rendering. If you think about it that is what you expect. The same framework (or nearly so) is used to do the rendering both on your PC at design time and later on the device at runtime. The issue is that the design time attributes were not added to the compact framework (I assume to reduce the size).

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top