Reputation: 3748
The image is not showing with the below code in Xamarin. Its in images folder.
var image = new Image { Aspect = Aspect.AspectFit };
image.Source = "images/image1.png";
Content = image;
How can I fix this ?
Note : I'm using a Forms application.
Upvotes: 0
Views: 419
Reputation: 3701
You have to place the images in the right folder of each platform-project.
You can find more Infos here.
Edit (images in PCL-project)
To embed an image in a project, right-click to add new items and select the image/s you wish to add. By default the image will have Build Action: None; this needs to be set to Build Action: EmbeddedResource.
And then load the Image FromResource(..)
:
var embeddedImage = new Image { Aspect = Aspect.AspectFit };
embeddedImage.Source = ImageSource.FromResource("test.jpg");
To load images from the PCL-Project -> look at this page.
Upvotes: 1