Articles in this section
Category / Section

How to Filter the items in WPF AutoComplete Control?

1 min read

      Autocomplete control allows to filter the items by SuggestionMode Property.

It can be enabled or disabled by setting the SuggestionMode value of Autocomplete as Contains, StartsWith, Equals or Custom .

The same has been explained in the following code snippet:

XAML:

//Code Explains how to filter the items in Autocomplete control
<Window x:Class="AutoComplete.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:AutoComplete"
xmlns:syncfusion="http://schemas.syncfusion.com/wpf"
Title="MainWindow" Height="350" Width="525">
 <Grid> 

   <syncfusion:SfAutocomplete x:Name="Autocomplete"


AutoCompleteSource ="{Binding item}"


SearchItemPath="item"


SuggestionMode="Contains"


AutoCompleteMode="Suggest"


HorizontalAlignment="Center" VerticalAlignment="Top"


Height="40" Width="150" Margin="176,125,177,0"/>


</Grid>


</Window>


C#:

//Code explains how to filter the items in AutoComplte control
namespace AutoComplete
{
 public partial class MainWindow : Window
 {
     AutoCompleteList obj = new AutoCompleteList();
     public MainWindow()
     {
          InitializeComponent();
          Autocomplete.AutoCompleteSource = obj;
     }
  }
public class Autocomplete { public string item { get; set; }
public class AutocompleteList : List<AutoComplete> { public AutoCompleteList() { this.Add(new Autocomplete() { item = "item 1" }); this.Add(new Autocomplete() { item = "item 2" }); this.Add(new Autocomplete() { item = "item 3" }); this.Add(new Autocomplete() { item = "item 4" }); this.Add(new Autocomplete() { item = "item 5" }); this.Add(new Autocomplete() { item = "item 6" }); } } }

 

Output:

Filter Enable

C:\Users\Ashok.Murugesan\Desktop\Switchmode\AutoCompleteControl(IsFilterEnable).png

Filter Disable:

C:\Users\Ashok.Murugesan\Desktop\Switchmode\AutoCompleteControl(IsFilterDisable).png

Conclusion

I hope you enjoyed learning about how to Filter the items in Autocomplete Control.

You can refer to our WPF AutoComplete featuretour page to know about its other groundbreaking feature representations and documentation, and how to quickly get started for configuration specifications. You can also explore our WPF AutoComplete example to understand how to create and manipulate data.

For current customers, you can check out our components from the License and Downloads page. If you are new to Syncfusion, you can try our 30-day free trial to check out our other controls.

If you have any queries or require clarifications, please let us know in the comments section below. You can also contact us through our support forumsDirect-Trac, or feedback portal. We are always happy to assist you!

Did you find this information helpful?
Yes
No
Help us improve this page
Please provide feedback or comments
Comments (0)
Please sign in to leave a comment
Access denied
Access denied