We begin by setting the source of the image. The image control (referred to as image in the code) has a source property. This property is of the ImageSource abstract type. There are a few different types of image sources that you can use. The one we are interested in is the UriImageSource type, which takes a URI, downloads the image, and allows the image control to display it.
Let's extend the Swiper control to set the source and description, by doing the following:
- Open the Controls/Swiper.Xaml.cs file (the code-behind for the Swiper control).
- Add a using statement for Swiper.Utils (using Swiper.Utils;).
- Add the following code marked in bold to the constructor:
public SwiperControl()
{
InitializeComponent();
var picture = new Picture();
descriptionLabel.Text = picture.Description;
image.Source = new UriImageSource() { Uri = picture.Uri };
}
We create a new instance of a Picture class and assign the description to the descriptionLabel...