Set Image Source Property in Windows Phone App Project
If you are using Image control on your Windows Phone 8 app pages, you can set Image.Source property using ImageSourceConverter class and its ConvertFromString method. In this Visual Studio 2012 Windows Phone app programming tutorial, I'll show how to set source of image control using VB.NET code where the image is placed on MainPage.xaml at design time.
Use ImageSourceConverter in Windows Phone 8 App Code Behind
Assume that I have an image control named "image" placed on page .xaml design code as follows.
Now let's set .XAML Image Source value using VB.NET. In VB.NET code behind of this Windows Phone 8 app page, use following ImageSourceConverter class and ConvertFromString method code to set Image.Source property of this image control to a relative URL pointing to an image within the app project assets.
Here is a sample of the output where a dummy image is displayed at the bottom of the Windows Phone app page. Using Visual Studio 2012 WP8 development IDE, we have set image source property of the XAML Image control placed on page at design time. When we run the app the image we want is displayed.
Set source of an Image control programatically using ImageSourceConverter class and ConvertFromString method