DependencyPropertyChangedEventArgs DependencyPropertyChangedEventArgs DependencyPropertyChangedEventArgs DependencyPropertyChangedEventArgs Struct

Définition

Fournit des données pour différents événements de modification de propriété.Provides data for various property changed events. En général, ces événements font état des modifications effectives de valeurs dans la valeur d’une propriété de dépendance en lecture seule.Typically these events report effective value changes in the value of a read-only dependency property. Il est aussi possible de l’utiliser dans le cadre d’une implémentation de PropertyChangedCallback.Another usage is as part of a PropertyChangedCallback implementation.

public value class DependencyPropertyChangedEventArgs
public struct DependencyPropertyChangedEventArgs
type DependencyPropertyChangedEventArgs = struct
Public Structure DependencyPropertyChangedEventArgs
Héritage
DependencyPropertyChangedEventArgsDependencyPropertyChangedEventArgsDependencyPropertyChangedEventArgsDependencyPropertyChangedEventArgs

Exemples

L’exemple suivant utilise la DependencyPropertyChangedEventArgs classe dans le contexte PropertyChangedCallback d’un pour une propriété particulière d’une classe personnalisée qui définit également des événements.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. Le rappel prend les résultats des valeurs anciennes et nouvelles du système de propriétés comme communiqué par DependencyPropertyChangedEventArgs, et les reconditionne dans une classe RoutedPropertyChangedEventArgs<T>d’arguments d’événements différente.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>. Les nouveaux arguments sont ensuite utilisés comme données pour un événement «ValueChanged» défini par et déclenchés par la classe personnalisée.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

Remarques

Les événements qui utilisent la DependencyPropertyChangedEventArgs classe pour les données d’événement et DependencyPropertyChangedEventHandler les implémentations de méthode pour les gestionnaires, suivent généralement le Is*Changedmodèle d’affectation de noms et Common Language Runtime (CLR)common language runtime (CLR) sont généralement RoutedEvent implémentés en tant qu’événements sans sauvegarde (il ne s’agit pas d’événements routés).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). Certaines méthodes de gestion de classe qui «gèrent», sinon les événements non exposés qui signalent un changement d’état via ButtonBase.OnIsPressedChangedune modification de propriété DependencyPropertyChangedEventArgs , tels que, utilisent également la classe pour les données d’événement.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.

Le scénario pour PropertyChangedCallback consiste à utiliser les arguments pour signaler les valeurs anciennes et nouvelles provenant de l’évaluation du système de propriétés de la propriété.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. Un rappel qui traite les valeurs anciennes et nouvelles peut choisir un traitement spécial en fonction de ces valeurs, par exemple choisir de ne pas répondre aux modifications de valeur jugées non significatives.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.

Constructeurs

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

Initialise une nouvelle instance de la classe DependencyPropertyChangedEventArgs.Initializes a new instance of the DependencyPropertyChangedEventArgs class.

Propriétés

NewValue NewValue NewValue NewValue

Obtient ou définit la propriété après modification.Gets the value of the property after the change.

OldValue OldValue OldValue OldValue

Obtient la valeur de la propriété avant modification.Gets the value of the property before the change.

Property Property Property Property

Obtient l'identificateur pour la propriété de dépendance où la valeur a été modifiée.Gets the identifier for the dependency property where the value change occurred.

Méthodes

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

Détermine si l'objet fourni est équivalent au DependencyPropertyChangedEventArgs actuel.Determines whether the provided object is equivalent to the current DependencyPropertyChangedEventArgs.

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

Détermine si le DependencyPropertyChangedEventArgs spécifié est équivalent au DependencyPropertyChangedEventArgs actuel.Determines whether the provided DependencyPropertyChangedEventArgs is equivalent to the current DependencyPropertyChangedEventArgs.

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

Obtient un code de hachage pour ce DependencyPropertyChangedEventArgs.Gets a hash code for this DependencyPropertyChangedEventArgs.

Opérateurs

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

Détermine si deux objets DependencyPropertyChangedEventArgs spécifiés ont la même valeur.Determines whether two specified DependencyPropertyChangedEventArgs objects have the same value.

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

Détermine si deux objets DependencyPropertyChangedEventArgs spécifiés sont différents.Determines whether two specified DependencyPropertyChangedEventArgs objects are different.

S’applique à

Voir aussi