Is it really important to use pack URIs in WPF apps?

孤街浪徒 提交于 2019-12-23 07:57:55

问题


Why should we use those, rather than ordinary ones?

what's the benefits of using this:

new Uri("pack://application:,,,/File.xaml");

over that:

new Uri("/File.xaml", UriKind.Relative);

回答1:


The first one - you can use cross-assembly by adding a assembly-name after the three commas. So, you can create a shared library with common styles and other XAML-goodness that can be shared between several assemblies.

Syntax is like this:

pack://application:,,,/Common;component/CommonResources.xaml

where Common is the name of the assembly and everything after component is the path inside that assembly to the mapped resource. The latter can only be used inside the same assembly (and should be preferred).

I use it a lot for ResourceDictionaries residing in a common assembly above several module-type assemblies.



来源:https://stackoverflow.com/questions/3442000/is-it-really-important-to-use-pack-uris-in-wpf-apps

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!