How do I load an image from the Asset Catalog on cross-platform xamarin XAML?

两盒软妹~` 提交于 2019-12-05 18:47:39

Just to point out something that's probably obvious but caused me issues for ages - you can't use the LaunchImages set that comes with the asset catalog as it is not eligible to list in the Image dropdown. You have to create a new Image Set.

After I did this, the following answers suddenly worked (where they hadn't before):

Including the Asset Catalog folder in the project

Creating a storyboard that comes with a code-behind

don't use the .png extension in the XAML

<Image VerticalOptions="CenterAndExpand"
               HorizontalOptions="Center"
               Source="logo1"/>

In Xamarin Documentation they have clearly mentioned that- On iOS, the Page.Icon property can't be populated from an image in an asset catalog image set. Instead, load icon images for the Page.Icon property from the Resources folder in the iOS project.

We were testing on Xamarin Live Player on an IPhone, turns out Asset Catalogs are not yet supported. (https://twitter.com/praeclarum/status/941775333753217025?s=08)

Thanks for the replies!

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!