Javierkaiser
Javierkaiser

Reputation: 41

How to use Resources/Images in .net MAUI Blazor?

We are developing a .net MAUI app using the **Blazor **variant, no XAML. (.net 6)

If you put a image in the folder Resources/Images (as a MauiImage), you can use directly in XAML like

<Image Source="YourImage" /> 

But in Blazor, you can't use like

<img src="YourImage" />

I can't find any documentation on how to use it this way.

Workaround (Not Solution): To load images in Blazor, we have to put in the wwwroot folder, some subfolder like img.

<img src="img/YourImage" />

But this is not using the resources folder, just a static image loaded by html.

Does anyone knows how to use it correctly?

I tried to put the image in the Resources / Images folder. I was expecting being able to use it.

Upvotes: 4

Views: 1646

Answers (1)

Zack
Zack

Reputation: 1609

When you reference different project in blazor project, you should to use "_content" in reference.

like this:<img src="_content/.../images/xxx.png">

Upvotes: -2

Related Questions