DependencyPropertyChangedEventArgs DependencyPropertyChangedEventArgs DependencyPropertyChangedEventArgs DependencyPropertyChangedEventArgs Struct

Definição

Fornece dados para vários eventos alterados pela propriedade.Provides data for various property changed events. Normalmente, esses eventos relatam alterações de valor efetivo no valor de uma propriedade de dependência somente leitura.Typically these events report effective value changes in the value of a read-only dependency property. Outro uso é como parte de uma implementação PropertyChangedCallback.Another usage is as part of a PropertyChangedCallback implementation.

public value class DependencyPropertyChangedEventArgs
public struct DependencyPropertyChangedEventArgs
type DependencyPropertyChangedEventArgs = struct
Public Structure DependencyPropertyChangedEventArgs
Herança
DependencyPropertyChangedEventArgsDependencyPropertyChangedEventArgsDependencyPropertyChangedEventArgsDependencyPropertyChangedEventArgs

Exemplos

O exemplo a seguir usa DependencyPropertyChangedEventArgs a classe no contexto de um PropertyChangedCallback para uma propriedade específica de uma classe personalizada que também define eventos.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. O retorno de chamada usa os resultados de valores antigos e novos do sistema de propriedades conforme comunicado DependencyPropertyChangedEventArgspor e os reempacota em uma classe RoutedPropertyChangedEventArgs<T>de argumentos de eventos diferentes.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>. Os novos argumentos são usados como os dados para um evento "ValueChanged" definido pelo e gerados pela classe personalizada.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

Comentários

Os eventos que usam a DependencyPropertyChangedEventArgs classe para dados de evento e as DependencyPropertyChangedEventHandler implementações de método para manipuladores, geralmente seguem o Is*Changedpadrão de nomenclatura e geralmente são CLR (Common Language Runtime)common language runtime (CLR) implementados RoutedEvent como eventos sem fazendo backup (não são eventos roteados).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)common language runtime (CLR) events without RoutedEvent backing (they are not routed events). Alguns métodos de manipulação de classe que "manipulam" caso contrário eventos não expostos que relatam uma alteração de estado ButtonBase.OnIsPressedChangedpor meio de uma DependencyPropertyChangedEventArgs alteração de propriedade, como, também usam a classe para dados de evento.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.

O cenário do PropertyChangedCallback é usar os argumentos para relatar valores antigos e novos que venham da avaliação do sistema de propriedades da propriedade.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. Um retorno de chamada que processa valores antigos e novos pode escolher manipulação especial dependendo desses valores, como escolher não responder a alterações de valor que são consideradas insignificantes.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.

Construtores

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

Inicializa uma nova instância da classe DependencyPropertyChangedEventArgs.Initializes a new instance of the DependencyPropertyChangedEventArgs class.

Propriedades

NewValue NewValue NewValue NewValue

Obtém o valor da propriedade depois da alteração.Gets the value of the property after the change.

OldValue OldValue OldValue OldValue

Obtém o valor da propriedade antes da alteração.Gets the value of the property before the change.

Property Property Property Property

Obtém o identificador para a propriedade de dependência em que ocorreu a alteração de valor.Gets the identifier for the dependency property where the value change occurred.

Métodos

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

Determina se o objeto fornecido é equivalente ao DependencyPropertyChangedEventArgs atual.Determines whether the provided object is equivalent to the current DependencyPropertyChangedEventArgs.

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

Determina se o DependencyPropertyChangedEventArgs fornecido é equivalente ao DependencyPropertyChangedEventArgs atual.Determines whether the provided DependencyPropertyChangedEventArgs is equivalent to the current DependencyPropertyChangedEventArgs.

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

Obtém o código hash para esse DependencyPropertyChangedEventArgs.Gets a hash code for this DependencyPropertyChangedEventArgs.

Operadores

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

Determina se dois objetos DependencyPropertyChangedEventArgs especificados têm o mesmo valor.Determines whether two specified DependencyPropertyChangedEventArgs objects have the same value.

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

Determina se dois objetos DependencyPropertyChangedEventArgs especificados são diferentes.Determines whether two specified DependencyPropertyChangedEventArgs objects are different.

Aplica-se a

Veja também