DependencyPropertyChangedEventArgs DependencyPropertyChangedEventArgs DependencyPropertyChangedEventArgs DependencyPropertyChangedEventArgs Struct

Definition

Stellt Daten für verschiedene durch geänderte Eigenschaften ausgelöste Ereignisse bereit.Provides data for various property changed events. Diese Ereignisse melden normalerweise effektive Änderungen beim Wert einer schreibgeschützten Abhängigkeitseigenschaft.Typically these events report effective value changes in the value of a read-only dependency property. Eine weitere Verwendungsmöglichkeit ist als Teil einer PropertyChangedCallback-Implementierung.Another usage is as part of a PropertyChangedCallback implementation.

public value class DependencyPropertyChangedEventArgs
public struct DependencyPropertyChangedEventArgs
type DependencyPropertyChangedEventArgs = struct
Public Structure DependencyPropertyChangedEventArgs
Vererbung
DependencyPropertyChangedEventArgsDependencyPropertyChangedEventArgsDependencyPropertyChangedEventArgsDependencyPropertyChangedEventArgs

Beispiele

Im folgenden Beispiel wird die DependencyPropertyChangedEventArgs -Klasse im Kontext PropertyChangedCallback eines für eine bestimmte Eigenschaft einer benutzerdefinierten Klasse verwendet, die auch Ereignisse definiert.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. Der Rückruf übernimmt die Ergebnisse der alten und neuen Werte aus dem-Eigenschaften System, wie DependencyPropertyChangedEventArgsvon kommuniziert, und verpackt diese in eine andere Ereignisklasse RoutedPropertyChangedEventArgs<T>des Ereignisses.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>. Die neuen Argumente werden dann als Daten für ein "ValueChanged"-Ereignis verwendet, das von definiert und von der benutzerdefinierten Klasse ausgelöst wird.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

Hinweise

Die Ereignisse, die die DependencyPropertyChangedEventArgs -Klasse für Ereignisdaten verwenden, DependencyPropertyChangedEventHandler und die Methoden Implementierungen für Handler, folgen im Allgemeinen dem Is*ChangedBenennungs Muster und werden im Common Language Runtime (CLR)common language runtime (CLR) allgemeinen als RoutedEvent Ereignisse ohne unterstützen (es handelt sich nicht um Routing Ereignisse).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 Common Language Runtime (CLR)common language runtime (CLR) events without RoutedEvent backing (they are not routed events). Einige Klassen Behandlungsmethoden, die andernfalls nicht verfügbar gemachte Ereignisse behandeln, die eine Zustandsänderung durch eine Eigenschafts Änderung melden, ButtonBase.OnIsPressedChangedwie z. b DependencyPropertyChangedEventArgs ., verwenden auch die-Klasse für Ereignisdaten.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.

Das Szenario für PropertyChangedCallback besteht darin, die Argumente zum Melden von alten und neuen Werten zu verwenden, die aus der Auswertung des Eigenschaften Systems der Eigenschaft stammen.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. Ein Rückruf, der alte und neue Werte verarbeitet, kann eine spezielle Behandlung in Abhängigkeit von diesen Werten auswählen, z. b. das auswählen, nicht auf Wertänderungen zu reagieren, die als unbedeutend eingestuft werden.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.

Konstruktoren

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

Initialisiert eine neue Instanz der DependencyPropertyChangedEventArgs-Klasse.Initializes a new instance of the DependencyPropertyChangedEventArgs class.

Eigenschaften

NewValue NewValue NewValue NewValue

Ruft den Wert der Eigenschaft nach der Änderung ab.Gets the value of the property after the change.

OldValue OldValue OldValue OldValue

Ruft den Wert der Eigenschaft vor der Änderung ab.Gets the value of the property before the change.

Property Property Property Property

Ruft den Bezeichner für die Abhängigkeitseigenschaft ab, für die die Änderung des Werts aufgetreten ist.Gets the identifier for the dependency property where the value change occurred.

Methoden

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

Bestimmt, ob das angegebene Objekt dem aktuellen DependencyPropertyChangedEventArgs entspricht.Determines whether the provided object is equivalent to the current DependencyPropertyChangedEventArgs.

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

Bestimmt, ob das angegebene DependencyPropertyChangedEventArgs dem aktuellen DependencyPropertyChangedEventArgs entspricht.Determines whether the provided DependencyPropertyChangedEventArgs is equivalent to the current DependencyPropertyChangedEventArgs.

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

Ruft einen Hashcode für diese DependencyPropertyChangedEventArgs ab.Gets a hash code for this DependencyPropertyChangedEventArgs.

Operatoren

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

Bestimmt, ob zwei angegebene DependencyPropertyChangedEventArgs-Objekte denselben Wert haben.Determines whether two specified DependencyPropertyChangedEventArgs objects have the same value.

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

Bestimmt, ob zwei angegebene DependencyPropertyChangedEventArgs-Objekte ungleich sind.Determines whether two specified DependencyPropertyChangedEventArgs objects are different.

Gilt für:

Siehe auch