Avoiding Visual Studio designer errors when WPF resource is defined in separate project

前端 未结 3 1079
[愿得一人]
[愿得一人] 2020-12-08 19:10

How can I avoid Visual Studio designer errors when a WPF resource is defined in separate project?

I have three projects in a composite WPF application: the main appl

3条回答
  •  刺人心
    刺人心 (楼主)
    2020-12-08 19:43

    One possible solution is to use DynamicResource rather than StaticResource. The Visual Studio 2008 designer simply displays the controls without any styling, like VS2010 beta 1 does when it cannot resolve a StaticResource.

    Using DynamicResource is appropriate in situations where a particular style may change at runtime, like when skinning.

    I found some related questions supporting this:

    • Assembly-wide / root-level styles in WPF class library
    • What’s the difference between StaticResource and DynamicResource in WPF?
    • WPF - Dynamic vs Static Resources

    I also found someone who states that DynamicResource should be used whenever a resource is not local:

    • Static vs Dynamic Resources

提交回复
热议问题