首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >静态资源无法解析

静态资源无法解析
EN

Stack Overflow用户
提问于 2014-09-25 07:34:01
回答 1查看 4K关注 0票数 3

我试图在我的会计系统中实现MahApps风格--我遵循这里需要的步骤--使用MahApps的链接。

下面是我陷入错误的代码--资源appbar_cupcake无法解析--这是代码

代码语言:javascript
复制
<Controls:MetroWindow x:Class="Hassab_Accounting_System.MainWindow"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:Controls="clr-namespace:MahApps.Metro.Controls;assembly=MahApps.Metro"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    Title="MainWindow" Height="350" Width="525">
<Grid>

</Grid>
<Controls:MetroWindow.RightWindowCommands>
<Controls:WindowCommands>
<Button Content="settings" />
<Button>
  <StackPanel Orientation="Horizontal">
    <Rectangle Width="20" Height="20"
               Fill="{Binding RelativeSource={RelativeSource AncestorType=Button},    Path=Foreground}">
      <Rectangle.OpacityMask>
        <VisualBrush Stretch="Fill"
                     Visual="{StaticResource appbar_cupcake}" />
      </Rectangle.OpacityMask>
    </Rectangle>
    <TextBlock Margin="4 0 0 0"
               VerticalAlignment="Center"
               Text="deploy cupcakes" />
  </StackPanel>
  </Button>
  </Controls:WindowCommands>
  </Controls:MetroWindow.RightWindowCommands>
  </Controls:MetroWindow>
            `
   ![here is the error ][2]

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2014-09-25 08:21:35

假设您还没有这样做,因为它没有包含在问题中,请确保您包括资源文件,在您的例子中,icon.xaml位于文件顶部的ResourceDictionary中。

类似于:

代码语言:javascript
复制
<Window.Resources>
    <ResourceDictionary>
        <ResourceDictionary.MergedDictionaries>
            <ResourceDictionary Source="/Resource/icon.xaml" />
        </ResourceDictionary.MergedDictionaries>
    </ResourceDictionary>
</Window.Resources>

或者你的App.xaml:

代码语言:javascript
复制
<Application.Resources>
    <ResourceDictionary>
        <ResourceDictionary.MergedDictionaries>
             <ResourceDictionary Source="/Resource/icon.xaml" />
        </ResourceDictionary.MergedDictionaries>
    </ResourceDictionary>
</Application.Resources>
票数 3
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/26033050

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档