ApiInformation.IsEventPresent(String, String) 方法

定义

返回 true 或 false 以指示指定类型是否存在指定事件。

public:
 static bool IsEventPresent(Platform::String ^ typeName, Platform::String ^ eventName);
 static bool IsEventPresent(winrt::hstring const& typeName, winrt::hstring const& eventName);
public static bool IsEventPresent(string typeName, string eventName);
function isEventPresent(typeName, eventName)
Public Shared Function IsEventPresent (typeName As String, eventName As String) As Boolean

参数

typeName
String

Platform::String

winrt::hstring

类型的命名空间限定名称。

eventName
String

Platform::String

winrt::hstring

事件的名称。

返回

Boolean

bool

如果类型存在指定的事件,则为 True;否则为 false

示例

if (Windows.Foundation.Metadata.ApiInformation.IsEventPresent("Windows.Media.Core.AudioTrack", "OpenFailed"))
{
    Debug.WriteLine("Windows.Media.Core.AudioTrack.OpenFailed event found");
}
else
{
    Debug.WriteLine("Windows.Media.Core.AudioTrack.OpenFailed event NOT found");
}

适用于