李金龙李金龙李金龙李金龙李金龙李金龙李金龙李金龙

wpf 依赖属性

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;
}
posted @ 2013-10-23 09:59  btbear3  阅读(181)  评论(0)    收藏  举报
李金龙李金龙李金龙李金龙李金龙李金龙李金龙李金龙李金龙李金龙李金龙