【问题标题】:WinRT information: Cannot find a resource with the given keyWinRT 信息:找不到具有给定密钥的资源
【发布时间】:2015-07-07 17:10:22
【问题描述】:

我正在创建一个 Windows 通用应用程序,现在正在开发 Windows Phone 部分。我在 Storyboards.xaml 文件中放置了一个用于简单按钮动画的 Storyboard,并且我已将此文件与我的 App.xaml 资源合并。

<Application.Resources>
    <ResourceDictionary>
        <ResourceDictionary.MergedDictionaries>
            <ResourceDictionary Source="ms-appx:///Dictionaries/Templates.xaml"/>
            <ResourceDictionary Source="ms-appx:///Dictionaries/Storyboards.xaml"/>
        </ResourceDictionary.MergedDictionaries>
    </ResourceDictionary>
</Application.Resources>

我使用此代码定位情节提要

Storyboard sb = App.Current.Resources["StoryboardButton"] as Storyboard;

动画在主页上运行良好。但是一旦我转到其他页面并返回主页并重新启动动画,我就会收到此错误

WinRT information: Cannot find a resource with the given key.

我错过了什么?

【问题讨论】:

    标签: xaml windows-runtime win-universal-app resourcedictionary


    【解决方案1】:

    我看不到您如何定义 StoryboarButton,但请尝试将 x:Key="StoryboardButton" 添加到该定义中。

    【讨论】:

      猜你喜欢
      • 2017-02-05
      • 2017-02-27
      • 2017-02-26
      • 2022-01-24
      • 2022-06-15
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-08-22
      相关资源
      最近更新 更多