Pierpowl
Pierpowl

Reputation: 299

Cannot find a Resource with the Name/Key AppBarButtonStyle

Common style included in winrt are getting me an exception

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

this basic code fires Cannot find a Resource with the Name/Key AppBarButtonStyle exception

Common resources are included in my app.xaml and I can navigate through the definition of this style..

Am I missing something really big here?

ps: I've tried restarting VS

Upvotes: 4

Views: 2791

Answers (4)

AH.
AH.

Reputation: 3091

In Windows 8.1 the StandardStyles.xaml file which contained the AppBarButtonStyle has been removed. Instead you can use the AppBarButton as shown here:

<AppBarButton Icon="Play" Label="Play" />

Check this article by Tim Heuer: http://timheuer.com/blog/archive/2013/10/29/remove-standardstyles-xaml-from-windows-8-1-winrt-projects.aspx

Upvotes: 2

AleMasetto
AleMasetto

Reputation: 31

I fixed it by defining the AppBarButtonStyle before my customized styles that extend AppBarButtonStyle.

Upvotes: 1

Tony
Tony

Reputation: 21

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

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

如果将其放到某个页面的xmal内部的resource里,OK。

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

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

Upvotes: 2

Jerry Nixon
Jerry Nixon

Reputation: 31831

Here are your three possible reasons:

  1. Is /Common/StandardStyles.xaml still there ?
  2. Is AppBarButtonStyle still in /Common/StandardStyles.xaml ?
  3. Does App.xaml still reference /Common/StandardStyles.xaml ?

App.xaml should look something like this:

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

Best of luck!

Upvotes: 1

Related Questions