Enabling Blend (/ VS designer) to identify ItemContainerStyle for custom control in Silverlight 3.0

When designing custom controls we would want the users to customize the appearance of the items that is added up in some derived form of ItemsControl. Say we have a property “ItemContainerStyle”, we would want that to be customized in Blend as it does for ListBox,

img

Lets say, we have a property called “MyButtonStyle”. To enable this property to be recognized by the designer, we would have to implement the StyleTypedPropertyAttribute in the implemented class,

[StyleTypedProperty(Property = "MyButtonStyle", StyleTargetType = typeof(MyButton))]
public class MyButtonItems: ItemsControl

That’s it. Hope this helps.

-Fahad

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: