The built-in ComboBox in Silverlight is not powerful enough to cater our requirements of enterprise applications. In LOB (Line of business) applications, sometimes we need type-ahead behavior for combo boxes so that the available choices are filtered as the user starts typing. The AutoCompleteBox (previously included in Silverlight Toolkit but now a part of Silverlight 3 native controls) is a very powerful and flexible control, and in this article, we will look how we can customize the AutoCompleteBox to be used as a replacement for Combo Box/Drop Down.
What will we cover?
To begin the article, let's first define what functionalities we need to add to the AutoCompleteBox to make it behave like a type-ahead customizable drop down combo box. Here are our requirements:
- There should be a down-arrow like button that pops up the drop down with the available choices. Currently, the AutoCompleteBox is a simple textbox in its original shape.
- When an item is selected, bringing the drop down should show ALL the available choices. Currently, it only displays the selected one.
- If an item is selected and the drop down is opened, the selected item should be highlighted.
- The custom AutoCompleteBox should be useable for concrete object-to-object relationships (e.g.
SalesOrderDetail
object containing a reference to theProject
object, also called associations or navigational properties). - The custom implementation should be useable in foreign key relationships (e.g.
SalesOrderDetail
object containing a field calledProductID
).
Read more: CodeProject