FilteredItemsSourceProvider Class
A data provider that supplies suggestions for the AutoCompleteEdit in sync mode.
Namespace: DevExpress.Maui.Editors
Assembly: DevExpress.Maui.Editors.dll
NuGet Package: DevExpress.Maui.Editors
Declaration
public class FilteredItemsSourceProvider :
ItemsSourceProviderBase
Remarks
The FilteredItemsSourceProvider
filters the data item collection based on the filter settings. The filtered collection is then automatically assigned to the editor’s ItemsSource property.
Use the provider’s ItemsSource property to specify the collection of suggestions. The table below contains options that define how the provider searches for suggestions in the collection.
Property/Event | Description |
---|---|
Specifies whether suggestions should start with or contain the entered text. | |
Specifies culture and case rules used to compare the entered text with suggestions. | |
Specifies which data fields to search. |
Examples
The example below uses the FilteredItemsSourceProvider
to supply items for the AutoCompleteEdit.
<ContentPage.BindingContext>
<local:AutoCompleteEditViewModel/>
</ContentPage.BindingContext>
<dxe:AutoCompleteEdit>
<dxe:AutoCompleteEdit.ItemsSourceProvider>
<dxe:FilteredItemsSourceProvider ItemsSource="{Binding ItemsSource}"
FilterCondition="Contains"
FilterComparisonType="CurrentCultureIgnoreCase"
FilterMembers="Name, Capital"/>
</dxe:AutoCompleteEdit.ItemsSourceProvider>
<dxe:AutoCompleteEdit.ItemTemplate>
<DataTemplate>
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<Label Padding="10" Text="{Binding Name}" FontAttributes="Bold"/>
<Label Padding="10" Grid.Column="1" Text="{Binding Abbr}"/>
<Label Padding="10" Grid.Column="2" Text="{Binding Capital}" HorizontalTextAlignment="End"/>
</Grid>
</DataTemplate>
</dxe:AutoCompleteEdit.ItemTemplate>
</dxe:AutoCompleteEdit>
using System.Collections.Generic;
using System.ComponentModel;
using Microsoft.Maui.Controls;
namespace AutoCompleteEditExample {
public partial class MainPage : ContentPage {
public MainPage() {
InitializeComponent();
}
}
public class State {
public string Name { get; init; }
public string Abbr { get; init; }
public string Capital { get; init; }
}
public class AutoCompleteEditViewModel : INotifyPropertyChanged {
List<State> itemsSource = new List<State>();
public List<State> ItemsSource { get { return itemsSource; } set { itemsSource = value; OnPropertyChanged(nameof(ItemsSource)); } }
public AutoCompleteEditViewModel() {
ItemsSource.Add(new State() { Name = "California", Abbr = "CA", Capital = "Sacramento" });
ItemsSource.Add(new State() { Name = "Colorado", Abbr = "CO", Capital = "Denver" });
ItemsSource.Add(new State() { Name = "Connecticut", Abbr = "CT", Capital = "Hartford" });
}
public event PropertyChangedEventHandler PropertyChanged;
protected void OnPropertyChanged(string propertyName) {
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
}
}
}
The example below uses the FilteredItemsSourceProvider
to supply suggestions for the AutoCompleteColumn.
<ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:dxe="clr-namespace:DevExpress.Maui.Editors;assembly=DevExpress.Maui.Editors"
xmlns:dxg="clr-namespace:DevExpress.Maui.DataGrid;assembly=DevExpress.Maui.DataGrid"
xmlns:scg="clr-namespace:System.Collections.Generic;assembly=netstandard">
<ContentPage.Content>
<dxg:DataGridView ItemsSource="{Binding Path=Employees}">
<dxg:DataGridView.Columns>
<dxg:AutoCompleteColumn FieldName="JobTitle">
<dxg:AutoCompleteColumn.ItemsSourceProvider>
<dxe:FilteredItemsSourceProvider FilterCondition="Contains"
FilterComparisonType="CurrentCultureIgnoreCase">
<dxe:FilteredItemsSourceProvider.ItemsSource>
<scg:List x:TypeArguments="x:String">
<x:String>Chief Executive Officer</x:String>
<x:String>Network Administrator</x:String>
</scg:List>
</dxe:FilteredItemsSourceProvider.ItemsSource>
</dxe:FilteredItemsSourceProvider>
</dxg:AutoCompleteColumn.ItemsSourceProvider>
</dxg:AutoCompleteColumn>
</dxg:DataGridView.Columns>
</dxg:DataGridView>
</ContentPage.Content>
</ContentPage>