How to display Image for background on stacklayout in iOS project using xamarin

I’m trying to display a photo as a background on stacklayout.

  1. I create a folder in the iOS project under Resources (The strange thing is that the folder is not visible in Solution Explorer but is seen through Finder /on my Mac/)

  2. I put a name for the folder Images and inside I put a picture with the name Scattering.jpg

  3. Inside into my stacklayout I put this code:

     <StackLayout>
     <Image Source="Images/Scattering.jpg" HorizontalOptions="FillAndExpand" VerticalOptions="FillAndExpand" > </Image></StackLayout>
    

But the image does not appear.

I will attach a screenshot from my solution explorer and the finder on my mac.

In the solution explorer folder Images is not visible

In the Finder these folder Images are visible

Answer

Right click on the Solution -> Display Options -> Show All Files

Browse to iOS Resource folder and include Images folder (Right click, Include In Project)

Then, Right click on the image and make sure “Build Action” is BundleResource.

Set WithRequest and HeightRequest for the image to verify it’s appearing.