DependencyPropertyChangedEventArgs DependencyPropertyChangedEventArgs DependencyPropertyChangedEventArgs DependencyPropertyChangedEventArgs Struct

定義

さまざまなプロパティ変更イベントにデータを提供します。 Provides data for various property changed events. 通常、これらのイベントは、読み取り専用の依存関係プロパティの有効値の変更を報告します。 Typically these events report effective value changes in the value of a read-only dependency property. もう 1 つの用途は、PropertyChangedCallback 実装の一部として使用することです。 Another usage is as part of a PropertyChangedCallback implementation.

public value class DependencyPropertyChangedEventArgs
public struct DependencyPropertyChangedEventArgs
type DependencyPropertyChangedEventArgs = struct
Public Structure DependencyPropertyChangedEventArgs
継承
DependencyPropertyChangedEventArgsDependencyPropertyChangedEventArgsDependencyPropertyChangedEventArgsDependencyPropertyChangedEventArgs

次の例では、DependencyPropertyChangedEventArgsのコンテキストでクラスをPropertyChangedCallbackイベントも定義するカスタム クラスの特定のプロパティ。The following example uses the DependencyPropertyChangedEventArgs class in the context of a PropertyChangedCallback for a particular property of a custom class that also defines events. コールバックは、以前の結果と、プロパティ システムから新しい値で受け渡されるDependencyPropertyChangedEventArgs、これらのさまざまなイベント引数クラスには、RoutedPropertyChangedEventArgs<T>します。The callback takes the results of old and new values from the property system as communicated by DependencyPropertyChangedEventArgs, and repackages these into a different events arguments class RoutedPropertyChangedEventArgs<T>. 新しい引数は、"ValueChanged"のイベントによって定義され、カスタム クラスによって発生し、データとして使用されます。The new arguments are then used as the data for a "ValueChanged" event defined by and raised by the custom class.

public static readonly DependencyProperty ValueProperty =
    DependencyProperty.Register(
        "Value", typeof(decimal), typeof(NumericUpDown),
        new FrameworkPropertyMetadata(MinValue, new PropertyChangedCallback(OnValueChanged),
                                      new CoerceValueCallback(CoerceValue)));

private static object CoerceValue(DependencyObject element, object value)
{
    decimal newValue = (decimal)value;

    newValue = Math.Max(MinValue, Math.Min(MaxValue, newValue));

    return newValue;
}

private static void OnValueChanged(DependencyObject obj, DependencyPropertyChangedEventArgs args)
{
    NumericUpDown control = (NumericUpDown)obj;

    RoutedPropertyChangedEventArgs<decimal> e = new RoutedPropertyChangedEventArgs<decimal>(
        (decimal)args.OldValue, (decimal)args.NewValue, ValueChangedEvent);
    control.OnValueChanged(e);
}
/// <summary>
/// Identifies the ValueChanged routed event.
/// </summary>
public static readonly RoutedEvent ValueChangedEvent = EventManager.RegisterRoutedEvent(
    "ValueChanged", RoutingStrategy.Bubble,
    typeof(RoutedPropertyChangedEventHandler<decimal>), typeof(NumericUpDown));

/// <summary>
/// Occurs when the Value property changes.
/// </summary>
public event RoutedPropertyChangedEventHandler<decimal> ValueChanged
{
    add { AddHandler(ValueChangedEvent, value); }
    remove { RemoveHandler(ValueChangedEvent, value); }
}
/// <summary>
/// Raises the ValueChanged event.
/// </summary>
/// <param name="args">Arguments associated with the ValueChanged event.</param>
protected virtual void OnValueChanged(RoutedPropertyChangedEventArgs<decimal> args)
{
    RaiseEvent(args);
}
Public Shared ReadOnly ValueProperty As DependencyProperty = DependencyProperty.Register("Value", GetType(Decimal), GetType(NumericUpDown), New FrameworkPropertyMetadata(MinValue, New PropertyChangedCallback(AddressOf OnValueChanged), New CoerceValueCallback(AddressOf CoerceValue)))

Private Shared Overloads Function CoerceValue(ByVal element As DependencyObject, ByVal value As Object) As Object
	Dim newValue As Decimal = CDec(value)

	newValue = Math.Max(MinValue, Math.Min(MaxValue, newValue))

	Return newValue
End Function

Private Shared Sub OnValueChanged(ByVal obj As DependencyObject, ByVal args As DependencyPropertyChangedEventArgs)
	Dim control As NumericUpDown = CType(obj, NumericUpDown)

	Dim e As New RoutedPropertyChangedEventArgs(Of Decimal)(CDec(args.OldValue), CDec(args.NewValue), ValueChangedEvent)
	control.OnValueChanged(e)
End Sub
''' <summary>
''' Identifies the ValueChanged routed event.
''' </summary>
Public Shared ReadOnly ValueChangedEvent As RoutedEvent = EventManager.RegisterRoutedEvent("ValueChanged", RoutingStrategy.Bubble, GetType(RoutedPropertyChangedEventHandler(Of Decimal)), GetType(NumericUpDown))

''' <summary>
''' Occurs when the Value property changes.
''' </summary>
Public Custom Event ValueChanged As RoutedPropertyChangedEventHandler(Of Decimal)
	AddHandler(ByVal value As RoutedPropertyChangedEventHandler(Of Decimal))
		MyBase.AddHandler(ValueChangedEvent, value)
	End AddHandler
	RemoveHandler(ByVal value As RoutedPropertyChangedEventHandler(Of Decimal))
		MyBase.RemoveHandler(ValueChangedEvent, value)
	End RemoveHandler
	RaiseEvent(ByVal sender As System.Object, ByVal e As RoutedPropertyChangedEventArgs(Of Decimal))
	End RaiseEvent
End Event
''' <summary>
''' Raises the ValueChanged event.
''' </summary>
''' <param name="args">Arguments associated with the ValueChanged event.</param>
Protected Overridable Sub OnValueChanged(ByVal args As RoutedPropertyChangedEventArgs(Of Decimal))
	MyBase.RaiseEvent(args)
End Sub

注釈

使用するイベント、 DependencyPropertyChangedEventArgs 、イベント データ クラスとDependencyPropertyChangedEventHandlerハンドラーのメソッドの実装は、名前付けパターンを一般的に従いますIs*Changed、として実装は一般に共通言語ランタイム (CLR)common language runtime (CLR)イベントをRoutedEventバックアップ (ルーティング イベントではありません)。The events that use the DependencyPropertyChangedEventArgs class for event data, and the DependencyPropertyChangedEventHandler method implementations for handlers, generally follow the naming pattern Is*Changed, and are generally implemented as 共通言語ランタイム (CLR)common language runtime (CLR) events without RoutedEvent backing (they are not routed events). それ以外の場合"handle"メソッドを処理するクラスのいくつかのように、プロパティ変更を通じて状態の変更をレポートするイベントを露出されていないButtonBase.OnIsPressedChanged、使用しても、DependencyPropertyChangedEventArgsイベント データのクラス。Some class handling methods that "handle" otherwise unexposed events that report a state change through a property change, such as ButtonBase.OnIsPressedChanged, also use the DependencyPropertyChangedEventArgs class for event data.

シナリオは、PropertyChangedCallbackプロパティのプロパティ システムの評価から取得したレポートの新旧値の引数を使用することです。The scenario for PropertyChangedCallback is to use the arguments to report old and new values that come from the property system evaluation of the property. 新旧の値を処理するコールバックには、意味のないと思われる値の変更に応答しないように選択するなど、これらの値によって特別な処理こともできます。A callback that processes old and new values might choose special handling depending on these values, such as choosing to not respond to value changes that are deemed insignificant.

コンストラクター

DependencyPropertyChangedEventArgs(DependencyProperty, Object, Object) DependencyPropertyChangedEventArgs(DependencyProperty, Object, Object) DependencyPropertyChangedEventArgs(DependencyProperty, Object, Object) DependencyPropertyChangedEventArgs(DependencyProperty, Object, Object)

DependencyPropertyChangedEventArgs クラスの新しいインスタンスを初期化します。 Initializes a new instance of the DependencyPropertyChangedEventArgs class.

プロパティ

NewValue NewValue NewValue NewValue

変更後のプロパティの値を取得します。 Gets the value of the property after the change.

OldValue OldValue OldValue OldValue

変更前のプロパティの値を取得します。 Gets the value of the property before the change.

Property Property Property Property

値が変更された依存関係プロパティの識別子を取得します。 Gets the identifier for the dependency property where the value change occurred.

方法

Equals(Object) Equals(Object) Equals(Object) Equals(Object)

提供されたオブジェクトが現在の DependencyPropertyChangedEventArgs と等価であるかどうかを判断します。 Determines whether the provided object is equivalent to the current DependencyPropertyChangedEventArgs.

Equals(DependencyPropertyChangedEventArgs) Equals(DependencyPropertyChangedEventArgs) Equals(DependencyPropertyChangedEventArgs) Equals(DependencyPropertyChangedEventArgs)

提供された DependencyPropertyChangedEventArgs が現在の DependencyPropertyChangedEventArgs と等価であるかどうかを判断します。 Determines whether the provided DependencyPropertyChangedEventArgs is equivalent to the current DependencyPropertyChangedEventArgs.

GetHashCode() GetHashCode() GetHashCode() GetHashCode()

この DependencyPropertyChangedEventArgs のハッシュ コードを取得します。 Gets a hash code for this DependencyPropertyChangedEventArgs.

演算子

Equality(DependencyPropertyChangedEventArgs, DependencyPropertyChangedEventArgs) Equality(DependencyPropertyChangedEventArgs, DependencyPropertyChangedEventArgs) Equality(DependencyPropertyChangedEventArgs, DependencyPropertyChangedEventArgs) Equality(DependencyPropertyChangedEventArgs, DependencyPropertyChangedEventArgs)

指定した 2 つの DependencyPropertyChangedEventArgs オブジェクトの値が同一かどうかを判断します。 Determines whether two specified DependencyPropertyChangedEventArgs objects have the same value.

Inequality(DependencyPropertyChangedEventArgs, DependencyPropertyChangedEventArgs) Inequality(DependencyPropertyChangedEventArgs, DependencyPropertyChangedEventArgs) Inequality(DependencyPropertyChangedEventArgs, DependencyPropertyChangedEventArgs) Inequality(DependencyPropertyChangedEventArgs, DependencyPropertyChangedEventArgs)

指定した 2 つの DependencyPropertyChangedEventArgs オブジェクトが異なっているどうかを判断します。 Determines whether two specified DependencyPropertyChangedEventArgs objects are different.

適用対象

こちらもご覧ください