PropertyChangedCallback 委托

定义

表示在依赖属性的有效属性值更改时调用的回调。

public delegate void PropertyChangedCallback(DependencyObject ^ d, DependencyPropertyChangedEventArgs e);
public delegate void PropertyChangedCallback(DependencyObject d, DependencyPropertyChangedEventArgs e);
type PropertyChangedCallback = delegate of DependencyObject * DependencyPropertyChangedEventArgs -> unit
Public Delegate Sub PropertyChangedCallback(d As DependencyObject, e As DependencyPropertyChangedEventArgs)

参数

d
DependencyObject

属性值已更改的 DependencyObject

e
DependencyPropertyChangedEventArgs

跟踪对此属性有效值的更改的任何事件发出的事件数据。

示例

以下示例使用指定 a PropertyChangedCallback的签名注册新的依赖属性。 该 PropertyChangedCallback 函数用于创建每当公共属性更改时更改内部属性的回调。

public static readonly DependencyProperty AquariumGraphicProperty = DependencyProperty.Register(
  "AquariumGraphic",
  typeof(Uri),
  typeof(AquariumObject),
  new FrameworkPropertyMetadata(null,
      FrameworkPropertyMetadataOptions.AffectsRender, 
      new PropertyChangedCallback(OnUriChanged)
  )
);
Public Shared ReadOnly AquariumGraphicProperty As DependencyProperty = DependencyProperty.Register("AquariumGraphic", GetType(Uri), GetType(AquariumObject), New FrameworkPropertyMetadata(Nothing, FrameworkPropertyMetadataOptions.AffectsRender, New PropertyChangedCallback(AddressOf OnUriChanged)))
private static void OnUriChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) {
  Shape sh = (Shape) d;
  sh.Fill = new ImageBrush(new BitmapImage((Uri)e.NewValue));
}
Private Shared Sub OnUriChanged(ByVal d As DependencyObject, ByVal e As DependencyPropertyChangedEventArgs)
    Dim sh As Shape = CType(d, Shape)
    sh.Fill = New ImageBrush(New BitmapImage(CType(e.NewValue, Uri)))
End Sub

扩展方法

GetMethodInfo(Delegate)

获取指示指定委托表示的方法的对象。

适用于