共用方式為


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

追蹤這個屬性有效值變更之任何事件所發出的事件資料。

範例

下列範例會使用指定 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)

取得表示特定委派所代表之方法的物件。

適用於