Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is AutoComplete working on WPF?

Tags:

c#

wpf

textbox

I've a TextBox, can I autocomplete using 5 options that I've in a List?

It would be great if this could be done using Binding and XAML.

like image 859
Jaime Oro Avatar asked Dec 28 '22 00:12

Jaime Oro


1 Answers

There is no standard auto complete control in WPF. You can google for 3rd parties. But there is one very easy way to create simplistic auto complete control by slightly adjusting an editable ComboBox template:

<ComboBox IsEditable="True">
  <ComboBox.Template>
    <ControlTemplate TargetType="{x:Type ComboBox}">
      <TextBox x:Name="PART_EditableTextBox" />
    </ControlTemplate>
  </ComboBox.Template>
  <TextBlock Text="Hello"/>
  <TextBlock Text="World"/>
</ComboBox>     
like image 161
Anvaka Avatar answered Jan 08 '23 11:01

Anvaka