Let's say we are receiving the uriString as a parameter and we want to assign that string URI to an image control's source property. What we need to use is the Uri.IsWellFormedUriString(string uriString, UriKind uriKind) which will check that the URI is well formed and that it doesn't required further scaping:
public void SetImageSource(String uriString)
{
if (Uri.IsWellFormedUriString(uriString, UriKind.Absolute))
{
this.Thumbnail.Source = new BitmapImage(new Uri(uriString));
}
}
Then you can use the "else" block to set the thubmnail image of our control to a default well formed URI.
Hope it is useful for you.
Cheers!
-arbbot

0 comments:
Post a Comment