2012-12-14 30 views
4

包含在WinRT中常见的风格让我无法找到资源的名称/密钥AppBarButtonStyle

公共资源包括在我的App.xaml异常

<Button Style="{StaticResource AppBarButtonStyle}" /> 

这个基本的代码火灾Cannot find a Resource with the Name/Key AppBarButtonStyle例外,我可以浏览这种风格的定义。

我在这里错过了一些非常大的东西吗?

PS:我已经试过重新启动VS

回答

1

这里有你的三个可能的原因:

  1. 是/Common/StandardStyles.xaml还在吗?
  2. AppBarButtonStyle仍在/Common/StandardStyles.xaml?
  3. App.xaml仍然引用/Common/StandardStyles.xaml?

的App.xaml应该是这个样子:

<Application.Resources> 
    <ResourceDictionary> 
     <ResourceDictionary.MergedDictionaries> 
      <ResourceDictionary Source="Common/StandardStyles.xaml"/> 
     </ResourceDictionary.MergedDictionaries> 
    </ResourceDictionary> 
</Application.Resources> 

祝您好运!

1

我遇到这个问题是在一个单独的资源字典里定义

<Button Style="{StaticResource AppBarButtonStyle}" /> 

如果将其放到某个页面的Xmal位内部的资源里,OK。

我解决这个问题是在资源字典头部添加

<ResourceDictionary.MergedDictionaries> 
    <ResourceDictionary Source="Common/StandardStyles.xaml"/> 
</ResourceDictionary.MergedDictionaries> 
+10

任何机会,你可以用英文吗? –

1

我通过我以前的风格定制,扩展AppBarButtonStyle定义AppBarButtonStyle固定它。