0

I've created 3 Images for my context menu. The problem is that I can not see them in runtime. (I can see them in the editor window)

I've already

  • changed compile type to resource
  • and image type to png (just in case)

    <Color x:Key="BackgroundColor" A="255" R="19" G="19" B="19"/>
    
    <BitmapImage x:Key="BiCut" UriSource="Images/cut.tif"/>
    <BitmapImage x:Key="BiCopy" UriSource="Images/copy.tif"/>
    <BitmapImage x:Key="BiPaste" UriSource="Images/paste.tif"/>
    
    <SolidColorBrush x:Key="BorderBrush" Color="#ECECEC"/>
    
    <Style TargetType="ContextMenu">
        <Setter Property="Foreground" Value="{StaticResource BorderBrush}"/>
        <Setter Property="SnapsToDevicePixels" Value="True" />
        <Setter Property="OverridesDefaultStyle" Value="True" />
        <Setter Property="Grid.IsSharedSizeScope" Value="true" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="ContextMenu">
                    <Border BorderThickness="1" BorderBrush="#2468d9" Padding="2" Background="#131313">
                        <StackPanel Orientation="Horizontal">
                            <StackPanel Orientation="Horizontal" Height="20">
                                <Image Source="{StaticResource BiCut}" Width="20"/>
                                <Button Content="Ausschneiden" Margin="5,0,0,0"/>
                                <TextBlock Text="Strg+X" TextAlignment="Center" VerticalAlignment="Center" Margin="5,0,0,0"/>
                            </StackPanel>
                        </StackPanel>
                    </Border>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>
    

Sens4
  • 605
  • 1
  • 11
  • 29
  • Did you look at this question? http://stackoverflow.com/questions/8483002/image-shows-up-in-visual-studio-designer-but-not-during-run-time – d.moncada May 15 '15 at 14:54
  • My images are inside my project in `/Images/`. So I tried : ``. And again, I see it in the editor but not in runtime :( – Sens4 May 15 '15 at 15:59
  • When you say "changed compile type to resource" you actually mean that you set their Build Action to Resource? – Clemens May 15 '15 at 16:28
  • I've found the following link helpful a couple of times, it covers multiple scenarios, including resources being held in subfolders and in other assemblies. [link](http://www.abhisheksur.com/2010/04/pack-uri-to-reference-component.html) – User92 May 15 '15 at 17:46
  • Ty, but I think this isnt the problem, because in my editor I can see the image ? Correct me if I'm wrong – Sens4 May 15 '15 at 17:52
  • I'm not sure of why, but I've been in plenty of situations where the Xaml designer can display resources that seemingly can't be found at runtime.That is, until I've changed the URI. – User92 May 15 '15 at 17:58

1 Answers1

1

Okay well I solved it by simply drag the image, which I loaded into my project, into Source="<dragged image path>". It will insert the full path of the image.

Sens4
  • 605
  • 1
  • 11
  • 29