1

For some reason with this WPF project, I am getting the following exception in Blend:

enter image description here

This happens when one UserControl is inside another UserControl or Window. ItemBorder is a style that exists in a Resource Library linked to the application XAML file. It doesn't matter where I move this resource or its library. Even if I put it directly into the UserControl that is using it, I get this exception. Only when I make it a local value and not a resource does this exception go away. This exception only happens in Blend. It doesn't happen in Visual Studio (i'm using 2010), and it doesn't occur when I run the application.

I'm at the end of my rope here. This problem means I am completely unable to use Expression Blend.

H.B.
  • 166,899
  • 29
  • 327
  • 400
Jordan
  • 9,642
  • 10
  • 71
  • 141

1 Answers1

0

Tried making it a dynamic resource?

I am not especially clear on the rules in play that determine Static vs Dynamic even give the answer below, but It has resolved a lot of issues for me when loading resources to change it from a Static to Dynamicresource.

What's the difference between StaticResource and DynamicResource in WPF?

Alright, after a little digging, I found this. The OP in this post has a situation quite similar to yours. His work around suggests merging resource dictionaries at the Usercontrol level rather than only through App.xaml.

Community
  • 1
  • 1
CodeWarrior
  • 7,388
  • 7
  • 51
  • 78
  • A dynamic resource is simply one that can be changed after it is set. I suppose that I could try this, but I know that it is resource intensive to make your resources dynamic, so its not really a solution for my project. – Jordan Jul 18 '11 at 15:09
  • I haven't had a case when I changed resources after setting them, but I still have resources that are referred to through DynamicResource often enough. When you referenced the resource in Blend did you do so through the GUI or hand jam it? – CodeWarrior Jul 18 '11 at 15:13
  • This is a project started before we had blend. So a lot of it is manual yes. After using blend with other projects, I never want to go back to that. – Jordan Jul 18 '11 at 15:43
  • 1
    Any possibility that you could remove the resource call (just comment it out temporarily if you like) and try and find the resource through the Blend GUI. – CodeWarrior Jul 18 '11 at 21:18
  • Did that. I even moved (through the Blend GUI) the resource into the file that was using it, and it still gave me the in designer exception. – Jordan Jul 19 '11 at 13:11
  • I think that my problem was probably similar to this. I fixed my problem differently. I had a user control inside of a template that was in its own resource dictionary. I think it was an artifact of the days before Expression Blend; I think I thought I had to have a separate template in order to show custom items in a list control. I removed the template "middle-man" and everything works well. Thanks – Jordan Jul 19 '11 at 14:48