Sunday, September 20, 2009

Editing WPF Controls in Expression Blend

This is one of those quirks that until you try it, you may not know it exists or what the answer is.

I am working on a WPF project and have a separate control library (actually, a module because I am using the Component Application Guidance/PRISM pattern). I pulled it into Expression Blend and was surprised to see that I had no "design" view. The option simply didn't exist/was grayed out in the menu.

So, I did some digging around and it turns out that because my controls file is just a C# class library, Expression doesn't know it is "allowed" to design the controls. To tell it this, you simply need to open your .csproj file that the XAML is in, then add this to the first PropertyGroup tag that you find:

<PropertGroup>
...
<ProjectTypeGuids>{60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
...
</PropertyGroup>

Just enter it exactly with the same Guids ... now close out of Expression, reload, and voila! you can now design.

Jeremy Likness

6 comments:

  1. Thanks a ton for that tip.

    ReplyDelete
  2. Saved my life...
    I had put this in the main .csproj file, was not aware I had to put in them ALL... cheers!

    ReplyDelete
  3. Hi Jeremy,

    Over the last 2 years (seems like a lifetime) we've been building a large Silverlight PRISM / MEF application that makes use of dynamically loaded XAP modules and have recently upgraded to Blend 4, VS2010 and Prism 4 and now use MEF.

    However when editing a XAML file in Blend, we can't for the life of us see how to enable the XAML editing controls (design view). The objects and timeline is disabled, no states, assets, resources etc.

    We've tried the ProjectTypeGuids as above, we've added the existing projects to a new solution but still no joy.

    The solution modules were Class Libraries but then we changed the properties of the project indicate Silverlight Application and to output XAP. But being without Blend is a major for styling and creating templates etc.

    Do you know what the problem could be?

    Thanks - Simon

    ReplyDelete
  4. Do you get any errors when you attempt to edit the controls, or do they just not render/show disabled? Is it just that project, or do other projects show similar behavior? I have a few ideas but more information will help. Thanks!

    ReplyDelete
  5. Hi Jeremy - as an example our login form works normally in VS2010 - no XAML parser errors, we can work in the design and xaml views no problems, however when we open in Blend we get no design capability at all just the raw XAML. No errors though.

    ReplyDelete
  6. Nice concept about Editing WPF Controls in Expression Blend and hopefully here provided information and tricks will be sound good for everyone. So keep posting like this content so that a lot people will be able to benefited. Thanks :)

    ReplyDelete