Back to Devexpress

AsyncItemsSourceProvider.ItemsRequested Event

maui-devexpress-dot-maui-dot-editors-dot-asyncitemssourceprovider.md

latest2.9 KB
Original Source

AsyncItemsSourceProvider.ItemsRequested Event

Occurs when the provider requests editor items.

Namespace : DevExpress.Maui.Editors

Assembly : DevExpress.Maui.Editors.dll

NuGet Package : DevExpress.Maui.Editors

Declaration

csharp
public event EventHandler<ItemsRequestEventArgs> ItemsRequested

Event Data

The ItemsRequested event's data class is ItemsRequestEventArgs. The following properties provide information specific to this event:

PropertyDescription
CancellationTokenReturns the token that allows you to cancel the request.
RequestGets or sets the method that returns editor items.
RequestAsyncGets or sets the asynchronous method that returns editor items. This method has the higher priority than the Request event.
TextReturns the text entered in the edit box.

Example

The example below uses the AsyncItemsSourceProvider to supply suggestions for the AutoCompleteEdit.

xml
<dxe:AutoCompleteEdit LabelText="State"
                      PlaceholderText="Type here to search..."
                      VerticalOptions="Center"
                      Margin="16,0">
    <dxe:AutoCompleteEdit.ItemsSourceProvider>
        <dxe:AsyncItemsSourceProvider ItemsRequested="OnDelegateRequested" />
    </dxe:AutoCompleteEdit.ItemsSourceProvider>
</dxe:AutoCompleteEdit>
cs
using System.Collections.Generic;
using System.ComponentModel;
using Microsoft.Maui.Controls;

namespace AutoCompleteEditExample {
    public partial class MainPage : ContentPage {
        public MainPage() {
            InitializeComponent();
            States = new List<string>();
            States.AddRange(new string[] { "California", "Colorado", "Connecticut" /*...*/ });
        }
        public List<string> States { get; }
        void OnDelegateRequested(object sender, ItemsRequestEventArgs e) {
            e.Request = () => {
                return States.Where(i => i.StartsWith(e.Text, StringComparison.CurrentCultureIgnoreCase)).ToList();
            };
        }
    }
}

See Also

AsyncItemsSourceProvider Class

AsyncItemsSourceProvider Members

DevExpress.Maui.Editors Namespace