I currently have a very simple UserControl that only contains a single image. When I put this UserControl onto another window in the same project, the image no longer appears in the editor, nor does it appear when I run my program. I've looked at every question I can find on this, but I still haven't been able to get this working.
My user control is:
<UserControl x:Class="MyApp.DetailViews.InfoDetails"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
mc:Ignorable="d"
d:DesignHeight="20" d:DesignWidth="20">
<Grid>
<Image Source="/MyApp;component/Assets/Icon.png" HorizontalAlignment="Left" Height="20" VerticalAlignment="Top" Width="20"/>
</Grid>
I've checked these quesstions:
Embedded images not showing when in a UserControl
WPF - UserControl with images not showing properly
Why are my images not showing up in my UserControl?
Image in WPF Button not Visible at Runtime
The thing they seem to all have in common is the build settings for the components. As such, I've set the actual .png build action to Content and the Copy to Output Directory to Copy always.
The actual UserControl itself has it's Build Action set to page (although I've tried setting it to Content or Resource), and is set to Do not copy. These are the same settings as all my other UserControls, and I have no issues with those.
I have the following folder structure:
MyApp/MyApp.sln
MyApp/MainWindow.xaml/cs
MyApp/DetailViews/InfoDetails.xaml/cs
MyApp/Assets/Icon.png
What have I missed to make the image actually appear on the window?
Thanks.