public static void SetUrlSource(DependencyObject dependencyObject, string value)
{
dependencyObject.SetValue(UrlSourceProperty, value);
}
public static string GetUrlSource(DependencyObject dependencyObject)
{
return (string)dependencyObject.GetValue(UrlSourceProperty);
}
// Using a DependencyProperty as the backing store for UrlSource. This enables animation, styling, binding, etc...
public static readonly DependencyProperty UrlSourceProperty =
DependencyProperty.RegisterAttached("UrlSource", typeof(string), typeof(ImageSource), new PropertyMetadata("", new PropertyChangedCallback(SetSource)));
private static void SetSource(DependencyObject o, DependencyPropertyChangedEventArgs e)
{
Image images = o as Image;
if (images != null)
{
Uri u = new Uri(Application.Current.Host.Source, e.NewValue.ToString());
BitmapImage imgsrc = new BitmapImage(u);
images.Source = imgsrc;
}
}