Tuesday, February 02, 2010

AutoCompleteComboBox for Silverlight

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:

  1. 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.
  2. When an item is selected, bringing the drop down should show ALL the available choices. Currently, it only displays the selected one.
  3. If an item is selected and the drop down is opened, the selected item should be highlighted.
  4. The custom AutoCompleteBox should be useable for concrete object-to-object relationships (e.g. SalesOrderDetail object containing a reference to the Project object, also called associations or navigational properties).
  5. The custom implementation should be useable in foreign key relationships (e.g. SalesOrderDetail object containing a field called ProductID).
To address all these, we will create an AutoCompleteComboBox control that inherits the AutoCompleteBox and start adding the above features to it.


Read more: CodeProject

Posted via email from jasper22's posterous