开发者

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

开发者 https://www.devze.com 2023-01-11 06:40 出处:网络
Why should we use those, rather th开发者_开发问答an ordinary ones? what\'s the benefits of using this:

Why should we use those, rather th开发者_开发问答an ordinary ones?

what's the benefits of using this:

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

over that:

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


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消