Edit

Share via


AutomationPropertyChangedEventArgs(AutomationProperty, Object, Object) Constructor

Definition

Initializes a new instance of the AutomationPropertyChangedEventArgs class.

public:
 AutomationPropertyChangedEventArgs(System::Windows::Automation::AutomationProperty ^ property, System::Object ^ oldValue, System::Object ^ newValue);
public AutomationPropertyChangedEventArgs (System.Windows.Automation.AutomationProperty property, object oldValue, object newValue);
new System.Windows.Automation.AutomationPropertyChangedEventArgs : System.Windows.Automation.AutomationProperty * obj * obj -> System.Windows.Automation.AutomationPropertyChangedEventArgs
Public Sub New (property As AutomationProperty, oldValue As Object, newValue As Object)

Parameters

property
AutomationProperty

The identifier of the property that has changed.

oldValue
Object

The previous value of the property.

newValue
Object

The new value of the property.

Examples

The following example constructs and raises an event when a property has changed.

/// <summary>
/// Raises an event when the IsEnabled property on a control is changed.
/// </summary>
/// <param name="provider">The UI Automation provider for the control.</param>
/// <param name="newValue">The current enabled state.</param>
private void RaiseEnabledEvent(IRawElementProviderSimple provider, bool newValue)
{
    if (AutomationInteropProvider.ClientsAreListening)
    {
        AutomationPropertyChangedEventArgs args =
            new AutomationPropertyChangedEventArgs(AutomationElement.IsEnabledProperty,
                !newValue, newValue);
        AutomationInteropProvider.RaiseAutomationPropertyChangedEvent(provider, args);
    }
}
''' <summary>
''' Raises an event when the IsEnabled property on a control is changed.
''' </summary>
''' <param name="provider">The UI Automation provider for the control.</param>
''' <param name="newValue">The current enabled state.</param>
Private Sub RaiseEnabledEvent(ByVal provider As IRawElementProviderSimple, ByVal newValue As Boolean) 
    If AutomationInteropProvider.ClientsAreListening Then
        Dim args As New AutomationPropertyChangedEventArgs(AutomationElement.IsEnabledProperty, Not newValue, newValue)
        AutomationInteropProvider.RaiseAutomationPropertyChangedEvent(provider, args)
    End If

End Sub

Remarks

oldValue can be null (Nothing in Visual Basic) if the previous value is not readily available.

Applies to