Reputation: 75
The icons in my menu are showing in the design view but not at runtime.
Why?
I have tried both with and without pack://application :,,,
<Window x:Class="Aurora4XHelper.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:Aurora4XHelper"
mc:Ignorable="d"
Title="MainWindow" Height="350" Width="550">
<Grid Name="grid_Main">
<Menu IsMainMenu="True" x:Name="menu" DockPanel.Dock="Top" HorizontalAlignment="Left" Height="auto" VerticalAlignment="Top" Width="{Binding ElementName=grid_Main,Path=ActualWidth}">
<MenuItem Header="File">
<MenuItem Header="Exit" >
<MenuItem.Icon>
<Image Source="/Aurora4XHelper;component/Resources/Icons/Exit.png" />
</MenuItem.Icon>
</MenuItem>
</MenuItem>
<MenuItem Header="Design">
<MenuItem Header="Missile">
<MenuItem Header="Missile">
<MenuItem.Icon>
<Image Source="pack://application :,,,/Aurora4XHelper;component/Resources/Icons/Missile.png" />
</MenuItem.Icon>
</MenuItem>
<MenuItem Header="MIRV" />
<MenuItem Header="Bouy" />
<MenuItem Header="Mine" />
</MenuItem>
<MenuItem Header="Sensor" />
<MenuItem Header="Ship" />
<MenuItem Header="Terraforming"/>
</MenuItem>
</Menu>
</Grid>
Upvotes: 0
Views: 2445
Reputation: 692
Try to remove the /Aurora4XHelper;component/
part and just put <Image Source="Resources/Icons/Exit.png" />
instead.
Also make sure the BuildAction of the png file is set to Resource.
Upvotes: 1