AutomationPeer.ListenerExists(AutomationEvents) Method

Definition

获取一个值,该值指示 UI 自动化UI Automation是否正在侦听指定的事件。Gets a value that indicates whether UI 自动化UI Automation is listening for the specified event.

public:
 static bool ListenerExists(System::Windows::Automation::Peers::AutomationEvents eventId);
public static bool ListenerExists (System.Windows.Automation.Peers.AutomationEvents eventId);
static member ListenerExists : System.Windows.Automation.Peers.AutomationEvents -> bool
Public Shared Function ListenerExists (eventId As AutomationEvents) As Boolean

Parameters

eventId
AutomationEvents

枚举值之一。One of the enumeration values.

Returns

Boolean

指示 UI 自动化UI Automation是否正在侦听事件的 booleanA boolean that indicates whether UI 自动化UI Automation is listening for the event.

Remarks

通常,在创建引发事件的 AutomationPeer 之前调用此方法。Typically, you call this method before creating the AutomationPeer that raises the event. 此方法是一种性能度量,因为如果 UI 自动化UI Automation 不侦听事件,则创建一个对等方将无法进行此类事件。This method is a performance measure because if UI 自动化UI Automation does not listen for the event, it does not make sense to create a peer to raise one.

Note

此方法是静态的,仅当某个委托侦听 UI 自动化UI Automation中指定的事件,而不是在特定元素上的事件中侦听时的答案。This method is static and only answers if a delegate listens for the specified event in UI 自动化UI Automation, not for an event on a specific element. UI 自动化UI Automation 可以创建广播侦听器;因此,每个元素的信息是不相关的。can create broadcast listeners; therefore the per-element information is irrelevant.

Applies to

See also