从Universal 8.1应用程序的App.xaml中的共享项目访问Windows Phone项目中的Resource



我正在创建一个Windows Universal 8.1应用程序。在WindowsPhone8.1项目中,我有一个特定的Xaml文件作为ResourceDictionary。在共享文件夹中,我有两个项目(Windows和Windows Phone)的通用App.xaml。

ResourceDictionary的路径为:"MyApp.WindowsPhone/Assets/Styles/JumpList.xaml"

在App.xaml中,我添加了:

<ResourceDictionary>
   <ResourceDictionary.MergedDictionaries>
           <ResourceDictionary Source="MyApp.WindowsPhone/Assets/Styles/JumpList.xaml"/>
   </ResourceDictionary.MergedDictionaries>
</ResourceDictionary>

但我得到了:

An error occured while finding the resource dictionary "MyApp.WindowsPhone/Assets/Styles/JumpList.xaml"

知道我的路怎么了吗?

由于MyApp.WindowsPhone是根文件夹,您不需要指定它,因此可以将其声明为<ResourceDictionary Source="/Assets/Styles/JumpList.xaml"/>
通常,我们在一个名为styles as Assets的新文件夹中声明样式。该文件夹用于根据规范添加图像文件。

<ResourceDictionary Source="/Styles/JumpList.xaml"/>

最新更新