.NET MAUI Chat ItemPicker
The RadChatPicker
control provides an ItemPickerContext
that enables you to display a list of options the end user can choose from.
ItemPickerContext
exposes the following properties that allow you to show a list of possible options to the user:
-
ItemsSource
—Defines the data source used to generate the content of theItemPicker
control; -
SelectionMode
—Defines whether users are allowed to select one or many items out of the providedItemsSource
; -
SelectedItems
—Defines the currently selected items; -
SelectedItem
—Defines the last selected item;
The following example shows how to use the ItemPicker
ItemPickerContext context = new ItemPickerContext
{
ItemsSource = new List<string>() { "2 days", "5 days", "7 days", "Another period" }
};
PickerItem pickerItem = new PickerItem { Context = context, HeaderText = "Select an item" };
chat.Items.Add(pickerItem);
context.PropertyChanged += (s, e) =>
{
if (e.PropertyName == "SelectedItem")
{
if (context.SelectedItem != null)
{
chat.Items.Remove(pickerItem);
chat.Items.Add(new TextMessage { Author = chat.Author, Text = "" + context.SelectedItem });
}
}
};