语言

AppNotificationComboBox 类

定义

表示在应用通知上显示的组合框。

public ref class AppNotificationComboBox sealed
/// [Windows.Foundation.Metadata.Activatable(Microsoft.Windows.AppNotifications.Builder.IAppNotificationComboBoxFactory, 65536, "Microsoft.Windows.AppNotifications.Builder.AppNotificationBuilderContract")]
/// [Windows.Foundation.Metadata.ContractVersion(Microsoft.Windows.AppNotifications.Builder.AppNotificationBuilderContract, 65536)]
/// [Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
/// [Windows.Foundation.Metadata.Threading(Windows.Foundation.Metadata.ThreadingModel.Both)]
class AppNotificationComboBox final
[Windows.Foundation.Metadata.Activatable(typeof(Microsoft.Windows.AppNotifications.Builder.IAppNotificationComboBoxFactory), 65536, "Microsoft.Windows.AppNotifications.Builder.AppNotificationBuilderContract")]
[Windows.Foundation.Metadata.ContractVersion(typeof(Microsoft.Windows.AppNotifications.Builder.AppNotificationBuilderContract), 65536)]
[Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
[Windows.Foundation.Metadata.Threading(Windows.Foundation.Metadata.ThreadingModel.Both)]
public sealed class AppNotificationComboBox
function AppNotificationComboBox(id)
Public NotInheritable Class AppNotificationComboBox
继承
Object Platform::Object IInspectable AppNotificationComboBox
属性

示例

以下示例演示如何将组合框添加到应用通知的 XML 有效负载。

var notification = new AppNotificationBuilder()
    .AddText("Notification text.")
    .AddComboBox(new AppNotificationComboBox("combobox_id")
        .SetTitle("Select an item:")
        .AddItem("id_one", "Item one")
        .AddItem("id_two", "Item two")
        .SetSelectedItem("id_one"))
    .BuildNotification();


AppNotificationManager.Default.Show(notification);

如果支持紧急方案,则生成的 XML 有效负载:

<toast>
    <visual>
        <binding template='ToastGeneric'>
            <text>Notification text.</text>
        </binding>
    </visual>
    <actions>
        <input id='combobox_id' type='selection' title='Select an item:' defaultInput='id_one'>
            <selection id='id_one' content='Item one'/>
            <selection id='id_two' content='Item two'/>
        </input>
    </actions>
</toast>

注解

通过调用 AppNotificationBuilder.AddComboBox 将组合框添加到应用通知的 XML 有效负载。 最多可以向单个应用通知添加 5 个输入。

构造函数

名称 说明
AppNotificationComboBox(String)

使用指定的 ID 初始化 AppNotificationComboBox 类的新实例。

属性

名称 说明
Items

获取或设置 AppNotificationComboBox 的项

SelectedItem

获取或设置应用通知组合框的选定项。

Title

获取或设置应用通知组合框的标题。

方法

名称 说明
AddItem(String, String)

将项添加到 AppNotificationComboBox。

SetSelectedItem(String)

设置应用通知组合框的选定项。

SetTitle(String)

设置应用通知组合框的标题。

适用于