Skip to content

Latest commit

 

History

History
75 lines (50 loc) · 2.47 KB

appnotificationcombobox_setselecteditem_1287745884.md

File metadata and controls

75 lines (50 loc) · 2.47 KB
-api-id -api-type
M:Microsoft.Windows.AppNotifications.Builder.AppNotificationComboBox.SetSelectedItem(System.String)
winrt method

Microsoft.Windows.AppNotifications.Builder.AppNotificationComboBox.SetSelectedItem(System.String)

-description

Sets the selected item for an app notification combo box.

-parameters

-param id

A string containing the ID of the selected item.

-returns

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

-remarks

You can also set the selected item with the AppNotificationComboBox.SelectedItem property.

Add items to a combo box by calling AppNotificationComboBox.AddItem or 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.

-see-also

-examples

The following example demonstrates the use of this method to set the selected item for 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>