AppNotificationComboBox.AddItem(String, String) Method

Definition

Adds an item to an AppNotificationComboBox.

public:
 virtual AppNotificationComboBox ^ AddItem(Platform::String ^ id, Platform::String ^ content) = AddItem;
AppNotificationComboBox AddItem(winrt::hstring const& id, winrt::hstring const& content);
public AppNotificationComboBox AddItem(string id, string content);
function addItem(id, content)
Public Function AddItem (id As String, content As String) As AppNotificationComboBox

Parameters

id
String

Platform::String

winrt::hstring

The id associated with the combo box item.

content
String

Platform::String

winrt::hstring

The text content for the combo box item.

Returns

Returns the AppNotificationComboBox instance so that additional method calls can be chained.

Examples

The following example demonstrates the use of this method to add items to the app notification combo box.

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);

The resulting XML payload if the urgent scenario is supported:

<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>

Remarks

You can also set the items for an app notification combo box with the AppNotificationComboBox.Items property.

For guidance on using the AppNotificationBuilder APIs to create the UI for app notifications, see App notification content.

For reference information about the XML schema for app notifications, see App notification content schema.

Applies to