共用方式為


AutomationPeer.ListenerExists Method

Microsoft Silverlight will reach end of support after October 2021. Learn more.

Gets a value that indicates whether UI Automation is listening for the specified event.

Namespace:  System.Windows.Automation.Peers
Assembly:  System.Windows (in System.Windows.dll)

Syntax

'Declaration
Public Shared Function ListenerExists ( _
    eventId As AutomationEvents _
) As Boolean
public static bool ListenerExists(
    AutomationEvents eventId
)

Parameters

Return Value

Type: System.Boolean
true if UI Automation is listening for the specified event; otherwise, false.

Remarks

Typically, you call this method before you create the AutomationPeer that raises the event. This method is a performance measure, because if UI Automation is not listening for the event, it does not make sense to create a peer to raise the event.

NoteNote:

This method is static. It returns true only if a delegate is listening for the specified event in UI Automation. It does not indicate whether the delegate is listening for an event on a specific object. UI Automation can create broadcast listeners. Therefore, the per-object information is irrelevant.

Version Information

Silverlight

Supported in: 5, 4, 3

Silverlight for Windows Phone

Supported in: Windows Phone OS 7.1, Windows Phone OS 7.0

Platforms

For a list of the operating systems and browsers that are supported by Silverlight, see Supported Operating Systems and Browsers.