AppNotificationButton.IsButtonStyleSupported 方法

定義

傳回值,指出目前裝置上的代理程式更新按鈕是否支援按鈕樣式。

public:
 static bool IsButtonStyleSupported();
 static bool IsButtonStyleSupported();
public static bool IsButtonStyleSupported();
function isButtonStyleSupported()
Public Shared Function IsButtonStyleSupported () As Boolean

傳回

Boolean

bool

如果支援按鈕樣式,則為 True;否則為 false。

範例

下列範例示範如何檢查是否支援代理程式更新按鈕樣式,如果是,請設定按鈕樣式。

var button = new AppNotificationButton("Reply")
    .AddArgument("action", "reply");

if(AppNotificationButton.IsButtonStyleSupported())
{
    button.SetButtonStyle(AppNotificationButtonStyle.Critical);
}

var builder = new AppNotificationBuilder()
    .AddText("Notification text.")
    .AddButton(button);

AppNotificationManager.Default.Show(builder.BuildNotification());

如果支援緊急案例,則產生的 XML 承載:

<toast>
    <visual>
        <binding template='ToastGeneric'>
            <text>Notification text.</text>
        </binding>
    </visual>
    <actions>
        <action content='Reply' arguments='action=reply' hint-toolTip='Click to reply.'/>
    </actions>
</toast>

備註

AppNotificationButton.SetButtonStyle方法可讓您從AppNotificationButtonStyle列舉中指定其中一個按鈕樣式,以提供一致的常見案例體驗。 只有 Windows 10 組建 19041 和更新版本才支援此功能。 這個方法可讓您在執行時間判斷目前裝置是否支援按鈕樣式。

如需使用 AppNotificationBuilder API 建立代理程式更新 UI 的指引,請參閱 代理程式更新內容

如需代理程式更新之 XML 架構的參考資訊,請參閱 代理程式更新內容架構

適用於