【问题标题】:Access ResourceDictionary in Windows Phone project from Shared project in App.xaml of Universal 8.1 App从 Universal 8.1 App 的 App.xaml 中的共享项目访问 Windows Phone 项目中的 ResourceDictionary
【发布时间】:2016-05-16 12:30:14
【问题描述】:

我正在创建一个 Windows Universal 8.1 应用程序。在Windows Phone 8.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"

知道我的路径有什么问题吗?

【问题讨论】:

    标签: c# xaml windows-phone-8.1 win-universal-app resourcedictionary


    【解决方案1】:

    由于MyApp.WindowsPhone 是根文件夹,您无需指定它,您可以将其声明为 &lt;ResourceDictionary Source="/Assets/Styles/JumpList.xaml"/&gt;
    通常我们在一个名为 Styles 的新文件夹中声明样式,作为 Assets 文件夹,用于根据规范添加图像文件。

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

    【讨论】:

    • App.xaml 存在于共享文件夹中,我还有一个 MyApp.Windows 文件夹和一个 MyApp.WndowsPhone 文件夹。所以 MyApp.WndowsPhone 不是我的根文件夹...
    • 是的,但是当通用应用程序部署到移动设备时,它会获取移动文件夹并将共享文件夹添加到其中,这样您的移动文件夹就会成为根目录。当您更改路径时,您的样式是否有效?
    • 是的,当我将 ResourceDictionary 放入 Shared 文件夹并按照您所说的命名路径时,它起作用了!但似乎我的 ResourceDictionary 有问题。我在其中设置了 JumpList 的样式,但出现此错误:Error 13 Unknown type 'JumpListItemBackgroundConverter' in XML namespace 'http://schemas.microsoft.com/winfx/2006/xaml/presentation' 关于此错误的任何想法?
    • JumpListItemBackgroundConverter 是一个自定义名称,可能有两个选项 1) 由于使用了 Converter 名称,因此必须在您的手机项目中的某处定义一个“转换器”类,您需要对其进行转换如果您要转移它,也可以到共享文件夹。 2)如果Jumplist是指ListView包含在semantic zoom中,那么您必须检查您是否没有在其中定义任何手机主题资源。
    猜你喜欢
    • 2015-04-27
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多