如果您使用资源字典文件,则必须使用Pack URI Scheme来解决这些文件。 例如:
下面的示例显示 位于引用的程序集的项目文件夹的根XAML资源文件包URI。
pack://application:,,,/ReferencedAssembly;component/ResourceFile.xaml
下面的例子显示了XAML资源文件 位于引用的程序集的项目文件夹的子文件夹的包URI。
pack://application:,,,/ReferencedAssembly;component/Subfolder/ResourceFile.xaml
下面的例子显示了XAML资源文件 位于引用,特定版本的 装配的项目文件夹的根文件夹的包URI。
pack://application:,,,/ReferencedAssembly;v1.0.0.1;component/ResourceFile.xaml
如果该文件位于输出文件夹,您可以使用源站点引用它:
下面的示例演示包URI原产 的XAML网站文件,存储在可执行程序集从其中启动的位置 。
pack://siteoforigin:,,,/SiteOfOriginFile.xaml
下面的示例示出了用于原点 文件的XAML部位,存储在子文件夹中,是相对于从该 应用程序的可执行组件被推出的位置包URI。
pack://siteoforigin:,,,/Subfolder/SiteOfOriginFile.xaml
举个例子:
<UserControl.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<!--A resource dictionary in the output folder in the Assets folder-->
<ResourceDictionary Source="pack://siteoforigin:,,,/Assets/OpenIconsDictionary.xaml"/>
<!--A resource dictionary packed in the Gui dll-->
<ResourceDictionary Source="pack://application:,,,/Gui;component/Assets/PackedIconsDictionary.xaml"/>
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</UserControl.Resources>
<!--In the output folder /Assets/OpenIconsDictionary.xaml (Build Action: Embedded Resource, Copy always)-->
<ResourceDictionary
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<BitmapImage x:Key="Icon"
UriSource="pack://siteoforigin:,,,/Images/image.png"/>
</ResourceDictionary>
<!--In Gui.dll in the folder /Assets/PackedIconsDictionary.xaml (Build Action: Page, Do not copy)-->
<ResourceDictionary
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<BitmapImage x:Key="Icon"
UriSource="pack://siteoforigin:,,,/Images/image.png"/>
</ResourceDictionary>
是否有OpenType字体有问题? – 2012-03-14 17:03:11
@ahmet你是什么意思?有效地,我没有找到任何使用.otf扩展名的示例,其中大多数使用.ttf扩展名...您认为我可以在此代码中使用.otf扩展名吗? – rad 2012-03-14 17:30:52
Silverlight支持OTF。你有没有试过直接参考?像这样:http://blogs.silverlight.net/blogs/msnow/archive/2008/09/25/silverlight-tip-of-the-day-46-font-support-in-silverlight.aspx – Jeremiah 2012-03-14 17:47:33