Blend 2.5 June Preview – Blend Templates editing issues
I have been using Expression Blend quite a lot these days and found out two odd things when designing Templates.
- When using generic.xaml file to store your component Control Template and related styles and VisualStates, it does not allow you to Edit the TemplateVisualStates from the States Panel. It is simply disable and you can’t modify the States durations and Storyboard.
- When fully editing Templates in Blend, the latter systematically prefixes XAML elements with “vsm” namespace. Although this has no incidence in the way you preview your templates and the VisualStates in Blend, it systematically make your application crashing at runtime when trying to use the VisualStateManager and when loading DataTemplate objects.
In order to solve the first issue, open your generic.xaml file from Expression Blend 2.5 June Preview and do not go in the xaml view but switch to the resources Panel and select the Control style to edit from there.
Note that every ControlTemplate in the generic.xaml is associated with a Control Class so the icon next to the name of the control style is reflecting the visual of that control.
The Template control is then displayed in the Design surface and this is what you end-up with, a States panel where you cannot edit your states and duration.

To solve this issue, switch back and forth between Design view and XAML view
and the States Panel will be editable again.
The Second issue is a bit more complex to discover and to solve. I actually don’t know today if it is related to Blend (even though it should not be prefixing all elements it is modifying) or the Silverlight Xaml Parser. Anyway, when you edit Templates with Blend, you can end-up with the following Xaml code.
Note the red circles on the screen shot in the upper picture. It shows where Blend actually inserts “vsm” namespace prefix to element properties. I even got the Style element being modified like this. The result is odd because you think it works because of Blend not complaining. This issue will simply make your States not transitioning and your storyboard not running. So, before you spend hours trying to look at your Control code to see where you made a mistake, make sure that those prefix are not present. On the other hand, it is normal to have vsm namespace prefix for VsualState, VisualStateGroup, VisualTransition, VisualStateManager elements.
Related to this prefix issue, when editing and creating Part Templates (DataTemplate) from a Style stored in the generic.xaml, Blend tends to store the DataTemplate declaration in the App.xaml resources dictionary. Again, what you end-up with is something similar to the screen shot below.
Even if this complies, you will get Runtime Error messages like “DataTemplate does not support Grid as Content” and again, you wonder why you have that because it compiles and DataTemplate do support Grid as Content !!
The solution is to remove all “vsm” namespace prefix from every element that is not a Visual* (VisualState, VisualTransition, VisualGroup, VisualStateManager …).