我们为什么要使用那些而不是普通的?
使用这个有什么好处:
new Uri("pack://application:,,,/File.xaml");
Run Code Online (Sandbox Code Playgroud)
在那之上:
new Uri("/File.xaml", UriKind.Relative);
Run Code Online (Sandbox Code Playgroud)
Gob*_*lin 11
第一个 - 您可以通过在三个逗号后添加程序集名称来使用交叉程序集.因此,您可以创建一个共享库,该库具有可在多个程序集之间共享的常见样式和其他XAML优点.
语法是这样的:
pack://application:,,,/Common;component/CommonResources.xaml
Run Code Online (Sandbox Code Playgroud)
Common是程序集的名称,component之后的所有内容都是该程序集内映射资源的路径.后者只能在同一个组件内使用(应该是首选).
我对于驻留在几个模块类型程序集之上的公共程序集中的ResourceDictionaries使用了很多.