Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

static resource cannot be resolved

I am trying to implement MahApps style in my accounting system I follow the step needed here the link that I used MahApps .

Here is the code that I have I stuck in a error the resource appbar_cupcake cannot be resolved here is the code

<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]

Exception

like image 359
Dexter90 Avatar asked Aug 15 '26 04:08

Dexter90


1 Answers

Assuming you haven't done this already, since it is not included in the question, make sure you include the resource file, in your case icon.xaml in the ResourceDictionary at the top of your file.

Something like:

<Window.Resources>
    <ResourceDictionary>
        <ResourceDictionary.MergedDictionaries>
            <ResourceDictionary Source="/Resource/icon.xaml" />
        </ResourceDictionary.MergedDictionaries>
    </ResourceDictionary>
</Window.Resources>

Or to your App.xaml like:

<Application.Resources>
    <ResourceDictionary>
        <ResourceDictionary.MergedDictionaries>
             <ResourceDictionary Source="/Resource/icon.xaml" />
        </ResourceDictionary.MergedDictionaries>
    </ResourceDictionary>
</Application.Resources>
like image 84
FishySwede Avatar answered Aug 16 '26 17:08

FishySwede