1
votes

I am trying to make myself an AutoCompleteTextBox that when typed into will show suggestions in a drop down.

I managed to get this working (with a few niggles) by writing a new user control from scratch.

However, after some reading it seems this "reinventing the wheel" approach is not recommended and it got me thinking the functionality i have is very close to a combo box, that has a textbox instead of a toggle button.

Is there any way for me to extend ComboBox, changing it's template slightly and allowing me to write a few methods for populating the drop down items based on the text entered?

2

2 Answers

2
votes

There is only one acceptable approach to autocomplete in a real application: http://blog.petegoo.com/index.php/2011/11/22/building-an-auto-complete-control-with-reactive-extensions-rx/

I could not be more serious.

3
votes

Reinventing the wheel is risky, but then again an AutoCompleteTextBox is logically not the same as a ComboBox. You might for example want to provide some callbacks to provide autocomplete items to the text box based on text entered instead of providing a single ItemsSource of all options possible. Also ComboBox displays all items in the ItemsSource and you would not have enough control to filter or reorder them. You could however look for existing solutions to this problem. There is one here for example. I have not tested it but Hermit Dave is known in the developer community, so it should be a good base for whatever you need. You could make changes to this control and contribute to the development and that would not be reinventing the wheel.