在这种情况下使用StaticResource会导致Blend引发错误 [英] Using StaticResource in this situation cause Blend raise error

查看:71
本文介绍了在这种情况下使用StaticResource会导致Blend引发错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


伙计们,
我不知道这是一个已知问题还是只是发生在我的机器。请告知。

Guys,
I don't know if it's a known-issue or it just happens on my machine. please advise.

重新生成情况:

1。在ResourceDictionary1.xaml中创建Style1。样式可以是任何东西,只需更改按钮的背景颜色。

1. Create Style1 in ResourceDictionary1.xaml. Style can be anything, just simple like change Background color of button.

2。将ResourceDictionary1.xaml合并到App.xaml。

2. Merge ResourceDictionary1.xaml into App.xaml.

3。创建一个包含按钮的usercontrol,并将Style1应用于该按钮。使用Style = {StaticResource Style1}

3. Create a usercontrol that contains a button and apply Style1 to that button. Use Style={StaticResource Style1}

4。将此UserControl添加到Window1.xaml。

4. Add this UserControl to Window1.xaml.

运行项目,一切正常,按钮按应用样式设置。

Run the project, everything is OK, button get styled as applied.

在DesignView中打开UserControl:OK。

Open UserControl in DesignView: OK.

在Blend中打开项目,出现错误,无法渲染windows1,因为找不到Style1。

Open project in Blend,  error raised and could not render windows1 because Style1 not found.

将参考StaticResource更改为DynamicResource,一切都解决了。

Change reference StaticResource to DynamicResource, everything is solved.

当我尝试在项目中将每个DynamicResource更改为StaticResource以加快我的WPF应用程序的性能时,我陷入了这种情况但这导致我的页面无法在设计视图中打开。

 I trapped into this situation when trying to change every DynamicResource to StaticResource in my project to speed up performance of my WPF app but this caused my pages cannot open in Design View.

推荐答案

我遇到了同样的问题。 Blend默认使用dynamicresources,当我将它们转换为静态资源时,它们将不再以混合方式呈现。但是,我正在阅读的任何地方都说应该尽可能使用staticResources,因为动态资源会将你的应用程序变成狗......你找到了问题的答案吗?
I am experiencing this same issue.  Blend uses dynamicresources by default, and when I convert them to static resources, they elements will no longer render in blend.  However, everywhere I'm reading says that one should use staticResources whenever possible because dynamic resources will turn your application into a dog...  did you find an answer to your question?


这篇关于在这种情况下使用StaticResource会导致Blend引发错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆