Prefix Characters Constraint in UWP AutoComplete (SfTextBoxExt)
10 May 20214 minutes to read
Instead of displaying suggestion list on each character entry, matches can be filtered and displayed after a few character entries. This can be done using the MinimumPrefixCharacters
property, and its default value is 1.
<Page
x:Class="TextBoxExtSample.MainPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:TextBoxExtSample"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
xmlns:editors="using:Syncfusion.UI.Xaml.Controls.Input"
Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
<Grid Background="{StaticResource ApplicationPageBackgroundThemeBrush}">
<editors:SfTextBoxExt x:Name="textBoxExt"
HorizontalAlignment="Center"
VerticalAlignment="Center"
AutoCompleteMode="Suggest"
Width="200"
MinimumPrefixCharacters="2">
</editors:SfTextBoxExt>
</Grid>
</Page>
using Syncfusion.UI.Xaml.Controls.Input;
using System.Collections.Generic;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
// The BlankPage item template is documented at https://go.microsoft.com/fwlink/?LinkId=402352&clcid=0x409.
namespace TextBoxExtSample
{
/// <summary>
/// An empty page that can be used on its own or navigated within a frame.
/// </summary>
public sealed partial class MainPage : Page
{
public MainPage()
{
this.InitializeComponent();
SfTextBoxExt textBoxExt = new SfTextBoxExt()
{
HorizontalAlignment = HorizontalAlignment.Center,
VerticalAlignment = VerticalAlignment.Center,
Width = 200,
AutoCompleteMode = AutoCompleteMode.Suggest,
MinimumPrefixCharacters = 2
};
List<string> list = new List<string>()
{
"India",
"Uganda",
"Ukraine",
"Canada",
"United Arab Emirates"
};
textBoxExt.AutoCompleteSource = list;
this.Content = textBoxExt;
}
}
}