locked
ResourceDictionary not editable in blend suddenly, though xaml looks OK RRS feed

  • Question

  • I have a resource dictionary that i have been populating with drawing brushes.  Suddenly, while it is still in my projects folder, the typical blend icon for a xaml page for this resource dictionary is now a white piece of paper, and blend will not open it.  If I use a xaml editor like kaxaml, the collection looks fine--standard resource dictionary full of elements each assigned an x:key.  I'm truly lost as to why blend will not render the resource dictionary;  it does not show up under resources either.  It is as if blend doesn't recognize it as a valid xaml page, though looking at it with kaxaml seems to show the RD is just fine.  Not to mention, if the xaml has mistakes, blend will still open the xaml and allow you to edit--but blend won't open this file at all.

    Has anyone run into this?
    Purkiss
    Tuesday, November 3, 2009 9:14 PM

Answers

  • I ran into the same problem and Unni Ravindranathan is pretty much right. Rather then editing the project file by hand though, you can select the Project>Properties in VS and change the BuildAction on your Xaml file to Page (the default), Resource or EmbeddedResource and it will still be editable in Blend. Unfortunately Blend doesn't recognize the BuildAction of Content which is also valid for a Xaml Resource Dictionary for times when you don't want your Xaml compiled, such as when you want to load it at runtime with System.Windows.Markup.XamlReader.Load which is what I was doing. To deal with this problem I moved my Xaml files that I wanted to load at runtime into their own project, set the files BuildAction to Page, added a PostBuild event to copy my Xaml files to the desired location and to remove the compiled dll that I didn't want. Kind of convoluted, hopefully MS will add support for the Content BuildAction sometime soon.
    • Marked as answer by Purkiss Thursday, February 18, 2010 4:38 PM
    Wednesday, December 2, 2009 11:00 PM

All replies

  • Make sure that the project file contains the right entry for including the ResourceDictionary - it should look something like

    <Page Include="MyResourceDictionary.xaml" />
    This posting is provided "AS IS" with no warranties, and confers no rights.
    Tuesday, November 3, 2009 9:54 PM
  • I ran into the same problem and Unni Ravindranathan is pretty much right. Rather then editing the project file by hand though, you can select the Project>Properties in VS and change the BuildAction on your Xaml file to Page (the default), Resource or EmbeddedResource and it will still be editable in Blend. Unfortunately Blend doesn't recognize the BuildAction of Content which is also valid for a Xaml Resource Dictionary for times when you don't want your Xaml compiled, such as when you want to load it at runtime with System.Windows.Markup.XamlReader.Load which is what I was doing. To deal with this problem I moved my Xaml files that I wanted to load at runtime into their own project, set the files BuildAction to Page, added a PostBuild event to copy my Xaml files to the desired location and to remove the compiled dll that I didn't want. Kind of convoluted, hopefully MS will add support for the Content BuildAction sometime soon.
    • Marked as answer by Purkiss Thursday, February 18, 2010 4:38 PM
    Wednesday, December 2, 2009 11:00 PM
  • daGISguy, I actually opened a help ticket with MS on this topic and you are exactly right.  They are re-evaluating how blend handles this based on the number of complaints they have gotten.  They made this change from Blend 2 to Blend 3 to accommodate the Blend source and xaml itself... wild.  My work around is this:

    In the project, I keep two copies of the resource dictionary.  One that I edit with blend, and then the one with the build actions changed that blend won't render.  I make my changes to the blend friendly one, then copy and paste the xaml out of it and into the other.  Since my resource dictionary is full of vector ARTWORK, there's no way for me to intelligently manage the dictionary without some sort of UI.

    Thanks for the help guys.

    Purkiss
    Thursday, February 18, 2010 4:38 PM