Share via


AppNotificationComboBox.SelectedItem Property

Definition

Gets or sets the selected item for an app notification combo box.

public:
 property Platform::String ^ SelectedItem { Platform::String ^ get(); void set(Platform::String ^ value); };
winrt::hstring SelectedItem();

void SelectedItem(winrt::hstring value);
public string SelectedItem { get; set; }
var string = appNotificationComboBox.selectedItem;
appNotificationComboBox.selectedItem = string;
Public Property SelectedItem As String

Property Value

String

Platform::String

winrt::hstring

A string containing the ID of the selected item.

Examples

The following example demonstrates the use of this property to set the selected item for the app notification combo box.

var comboBox = new AppNotificationComboBox("combobox_id");
comboBox.Title = "Select an item:";
comboBox.Items = new Dictionary<string, string> { { "id_one", "Item one" }, { "id_two", "Item two" } };
comboBox.SelectedItem = "id_one";

var notification = new AppNotificationBuilder()
    .AddText("Notification text.")
    .AddComboBox(comboBox)
    .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 selected item by calling AppNotificationComboBox.SetSelectedItem).

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.

Applies to