Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Image tag in WPF in .net core 3.0 not working

I am working on a WPF application using .net core 3.0 preview.

I tried the following line of xaml code in both .net core 3.0 preview and .net framework.

<Grid>
    <Image Source="system-tray.jpg"/>
</Grid>

This works fine in .Net Framework but doesn't work in .Net Core 3.0 preview

Any thoughts!..

like image 372
Alen Alex Avatar asked Feb 19 '19 10:02

Alen Alex


1 Answers

For those coming by here in the future looking for an answer, like I did, here's the thing to check:

Make sure the Build Action for your image files in Visual Studio is set to "Resource". This can be checked by right-clicking the image file in the Solution Explorer and selecting "Properties".

Source: github.com/dotnet/wpf/issues/292 per question comment by Clemens

like image 191
JaykeBird Avatar answered Oct 19 '22 11:10

JaykeBird