简体   繁体   中英

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.

在解决方案资源管理器文件夹中,图像不可见

在 Finder 中,这些文件夹图像可见

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM