Skip to content

An attached behavior for WPF's TextBox control that provides auto-completion suggestions from a given collection

License

Notifications You must be signed in to change notification settings

ChangePlaces/WPFTextBoxAutoComplete

 
 

Repository files navigation

WPFTextBoxAutoComplete

An attached behavior for WPF's TextBox control that provides auto-completion suggestions from a given collection

How to use this library:

  1. Install the package via NuGet

    	PM> Install-Package WPFTextBoxAutoComplete
    
  2. Add a reference to the library in your view

    	xmlns:behaviors="clr-namespace:WPFTextBoxAutoComplete;assembly=WPFTextBoxAutoComplete"
  3. Create a textbox and bind the "AutoCompleteItemsSource" to a collection of IEnumerable<String>

    	<TextBox 
    		Width="250"
    		HorizontalAlignment="Center"
    		Text="{Binding TestText, UpdateSourceTrigger=PropertyChanged}" 
    		behaviors:AutoCompleteBehavior.AutoCompleteItemsSource="{Binding TestItems}" 
    	/>
  4. (Optional) Set the "AutoCompleteStringComparison" property, which is of type StringComparison

    	<TextBox 
    		Width="250"
    		HorizontalAlignment="Center"
    		Text="{Binding TestText, UpdateSourceTrigger=PropertyChanged}" 
    		behaviors:AutoCompleteBehavior.AutoCompleteItemsSource="{Binding TestItems}" 
    		behaviors:AutoCompleteBehavior.AutoCompleteStringComparison="InvariantCultureIgnoreCase"
    	/>

Now, every time the "TestText" property of your datacontext is changed, WPFTextBoxAutoComplete will provide you with auto-completion suggestions. To accept a suggestion, just hit "enter".

About

An attached behavior for WPF's TextBox control that provides auto-completion suggestions from a given collection

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • C# 100.0%