public static readonly DependencyProperty AquariumGraphicProperty = DependencyProperty.Register( "AquariumGraphic", typeof(Uri), typeof(AquariumObject), new PropertyMetadata(null, new PropertyChangedCallback(OnUriChanged) ) ); public Uri AquariumGraphic { get { return (Uri)GetValue(AquariumGraphicProperty); } set { SetValue(AquariumGraphicProperty, value); } }
private static void OnUriChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) { Shape sh = (Shape)d; ImageBrush ib = new ImageBrush(); ib.ImageSource = new BitmapImage(e.NewValue as Uri); sh.Fill = ib; }