本文整理汇总了VB.NET中System.Windows.Automation.Automation.AddAutomationPropertyChangedEventHandler方法的典型用法代码示例。如果您正苦于以下问题:VB.NET Automation.AddAutomationPropertyChangedEventHandler方法的具体用法?VB.NET Automation.AddAutomationPropertyChangedEventHandler怎么用?VB.NET Automation.AddAutomationPropertyChangedEventHandler使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。
在下文中一共展示了Automation.AddAutomationPropertyChangedEventHandler方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的VB.NET代码示例。
示例1: SubscribePropertyChange
Dim propChangeHandler As AutomationPropertyChangedEventHandler
''' <summary>
''' Adds a handler for property-changed event; in particular, a change in the enabled state.
''' </summary>
''' <param name="element">The UI Automation element whose state is being monitored.</param>
Public Sub SubscribePropertyChange(ByVal element As AutomationElement)
propChangeHandler = _
New AutomationPropertyChangedEventHandler(AddressOf OnPropertyChange)
Automation.AddAutomationPropertyChangedEventHandler(element, TreeScope.Element, _
propChangeHandler, AutomationElement.IsEnabledProperty)
End Sub
''' <summary>
''' Handler for property changes.
''' </summary>
''' <param name="src">The source whose properties changed.</param>
''' <param name="e">Event arguments.</param>
Private Sub OnPropertyChange(ByVal src As Object, ByVal e As AutomationPropertyChangedEventArgs)
Dim sourceElement As AutomationElement = DirectCast(src, AutomationElement)
If e.Property Is AutomationElement.IsEnabledProperty Then
Dim enabled As Boolean = CBool(e.NewValue)
' TODO: Do something with the new value.
' The element that raised the event can be identified by its runtime ID property.
Else
End If
' TODO: Handle other property-changed events.
End Sub
Public Sub UnsubscribePropertyChange(ByVal element As AutomationElement)
If (propChangeHandler IsNot Nothing) Then
Automation.RemoveAutomationPropertyChangedEventHandler(element, propChangeHandler)
End If
End Sub
开发者ID:VB.NET开发者,项目名称:System.Windows.Automation,代码行数:39,代码来源:Automation.AddAutomationPropertyChangedEventHandler