Call Images In Different Platforms Using Xamarin Forms

This article will describe how we will display images as an icon using Xamarin forms in different platforms. Let’s begin,
 
Firstly, you create a new Application in Visual Studio and select new project. After that select cross-platform, choose Blank App (Xamarin.Forms Portable) and mention project name for ex- TestApp, then click ok button as in the following figure 1.
 
 
Figure: 1
 
Once the project loads you can see the TestApp on top of Right-hand-side. Right Click that Portable TestApp project and Add New Item as in the following figure 2.
 
 
Figure:2
 
After that a dialog box will open, select cross-platform, then choose Forms.xaml Page and click Add button as in the following figure 3.
 
 
Figure: 3
 
Now create Forms.Xaml page in portable project. After that we will copy images from our system and paste images in the following location which I described below according to a different platform.
 
For Android – paste images in the Resources/drawable folder.
For iOS – paste images in the Resources folder.
For Windows Phone – paste images in the Assets folder.
 
As shown in figure 4.
 
 
Figure: 4
 
Now open the MainPage.xaml page and write the following code as shown in figure 5.
 
 
Figure: 5
 
The above code will find the appropriate folder and show images. These codes represent displayed images in different platforms like Android, iOS, Windows Phone. Finally, open the app.cs page and write the following code as shown in figure 6.
 
 
Figure: 6
 
Finally build your project, after success run it. Now you can see result in different platforms as figure 7.
 
 
Figure: 7
 
Summary
 
In this article we learned how to display images as an icon in different platforms using Xamarin forms. I hope you enjoyed this article.
 
You can visit my other articles related to Xamarin for more understanding:


Similar Articles