23 February 2010

Expression Blend 3 Design Time Attributes

Only a few people (including me until a few weeks ago) know that Expression Blend supports so called “Design Time Attributes”. These properties are very valuable to get “Design Time Data” into Blend. Without those example data designing DataTemplates is cumbersome and no fun. Those Design Time Attributes are not documented at all and I found out about them only by chance, reading some blogs. It seems that they are officially introduced with VS 2010 and documented there. Nevertheless they are fully functional with VS 2008 because they are ignored by the compiler and only used by design tools like blend.

All Design Time Attributes live in the d: namespace:

d:DesignHeight

In Blend, there is a special handle you can use to modify the d:DesignHeight and d:DesignWidth attributes without modifying the real Height attribute. This is handy if you just want to test some resizing logic.DesignTimeHeight

d:DesignWidth

DesignTimeWidth
d:DataContext Lets you specify the DataContext used at design time. Example: d:DataContext={StaticResource MyDataContextObject}, or even better    use d:DesignInstance

d:DesignInstance

d:DataContext="{d:DesignInstance Type=local:MyDataContext, IsDesignTimeCreatable=True}"

d:DesignData

needs VS2010, links to a sample data object defined in a xaml file

d:DesignSource

sets the Source property of a CollectionViewSource at design time

No comments:

Post a Comment