AutomationPropertyChangedEventArgs(AutomationProperty, Object, Object) 建構函式
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
初始化 AutomationPropertyChangedEventArgs 類別的新執行個體。
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)
參數
- property
- AutomationProperty
已變更之屬性的識別項。
- oldValue
- Object
屬性的舊值。
- newValue
- Object
屬性的新值。
範例
下列範例會在屬性變更時建構並引發 事件。
/// <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
備註
oldValue
如果先前的值尚未立即可用,可以在 null
Visual Basic 中 (Nothing
) 。