I don't understand why this code doesn't work
<Image Source="pack://application:,,,/Resources/Steam.png" Width="30"/>
https://stackoverflow.com/questions/62032643/using-image-in-xaml-from-resources-resx
how should I use embedded resource? I just don't want all the resources to be in the bin folder can someone help me on how to use EmbeddedResource in Xaml?
<Image Source="pack://application:,,,/Resources/Steam.png" Width="30"/>
<Image Source="/Resources/Steam.png" Width="30"/>
<ItemGroup>
<EmbeddedResource Include="Resources\Steam.png" />
</ItemGroup>
I tried many options but didn't work for me
I found an answer for you, although it is not in xaml. I've done a lot of research and couldn't find a xaml method, but it still is possible to keep the image as an embedded resource, without having it in your root app directory. You need to first put your images in a directory you can result to. and have the images set to "Embedded Resource" not "Resource" or anything else. In C# The code looks like this
Stream streamVar = this.GetType().Assembly.GetManifestResourceStream("YourProjectNameHere.TheDirectory(FormattedInPeriodsInsteadOfSlahses).YourImageHere.ImageExtensionType");
BitmapImage bitmapimageVar = new();
bitmapimageVar.SetSource(streamVar.AsRandomAccessStream());
YourXAMLUIImageElement.Source = sampleBitmapImageVariable;
Here is my Sample of code and directories
Stream s = this.GetType().Assembly.GetManifestResourceStream("Hostware.Icons.appicon.png");
BitmapImage img = new();
img.SetSource(s.AsRandomAccessStream());
appicon_image.Source = img;
Hope this helps! I spent too long trying to find an xaml method, if you have found a solution in xaml already, please let me know, because I want it