private void SetImage(string imageSource)
{
if(string.IsNullOrEmpty(imageSource))
{
_imageSource = null;
}
else
{
Uri imageUri;
bool validUri = Uri.TryCreate(imageSource, UriKind.RelativeOrAbsolute, out imageUri);
if(validUri)
{
// Once initialized, the image must be released so that it is usable by other resources
var btMap = new BitmapImage();
btMap.BeginInit();
btMap.UriSource = imageUri;
btMap.CacheOption = BitmapCacheOption.OnLoad;
btMap.EndInit();
_imageSource = btMap;
}
else
{
throw new UriFormatException(String.Format("Uri :{0} was not in the correct format", imageSource));
}
}
}