wpf - WPF 资源的范围 : Is pushing it to application scope (app. xaml) 对性能有好处吗?

标签 wpf resources resourcedictionary app.xaml

A)如果我有一个要从用户控件中使用的资源,哪一个更好的性能明智..?
要将其包含在用户控制范围本身中还是从 app.xaml 中引用资源 ..?

B) 现在我们拥有从 appl.xaml 引用的所有 100 种样式。
将它们移动到各自的用户控件是否值得付出努力..?

最佳答案

A) If I have a resource to be used from a user control, which one is more good performance wise..? To include it in the user control scope itself or refer the resource from app.xaml..?



由于 XAML 在 BAML 中编译,然后在启动时加载,因此您不会看到差异。现在大部分 XAML 的东西都是共享的(即线性画笔,下拉样式),所以最好不要将它直接放在控件上以重用相同的样式并分解

B) Now we have all the 100s of styles referred from appl.xaml. Will moving them to their respective user controls be worth the effort..?



适得其反,因为您将无法重用它们。

如果您的 XAML 速度很慢并且您使用的是 MVVM,请检查创建了多少对象。今年我遇到了一个问题,为每个项目重新创建一个上下文菜单,并将其共享给所有项目(在 TreeView 中)改进了初始化时间。

关于wpf - WPF 资源的范围 : Is pushing it to application scope (app. xaml) 对性能有好处吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8722831/

相关文章:

c# - 无法对 DataGrid 中的日期列进行排序

C++ 自定义二进制资源文件

wpf - 将 WPF 路径转换为位图文件

c# - 在 XAML 中访问代码隐藏变量

c# - WPF - TreeView 隐藏展开图标(箭头)

c# - 转到 TabControl wpf 的下一个 tabitem

delphi - 我该如何修复这个delphi 7编译错误 - "Duplicate resource(s)"

php - 是否有任何像样的 PHP 论坛可以让我提交程序设计和代码以供批评?

wpf - 在 WPF 用户控件库中的 UserControl 之间共享资源的最简单方法是什么?

xaml - 如何在 Windows Phone 8 中使用 ResourceDictionary 作为 StaticResource