← About Jeff

AutoCompleteBox: The 5 things you need to know

October 30, 2008

 
AutoCompleteBox works great with collections. You don't have to connect it to a sophisticated web service.

We named this control the AutoCompleteBox, not AutoComplete. Its different. It is a rich control that provides a set of suggestions, but not so much the old AJAX version that required you to wire the control up to a web service.

So, if you heard AutoComplete and got worried... don't. You can just bind it to simple data that you already have in your application.

<controls:AutoCompleteBox x:Name="State" ItemSource="{StaticResource StateCollection}" />

 
Have fun, give it some style.

As a composite control, AutoCompleteBox has a TextBox and usually a ListBox. The TextBoxStyle, ItemContainerStyle, and ItemTemplate properties are key to styling. And we expose the complete set of standard control visual states, plus PopupOpened and PopupClosed.

Changing the look of the text box part is easy:

<controls:AutoCompleteBox x:Name="Patient">
    <controls:AutoCompleteBox.TextBoxStyle>
        <Style TargetType="TextBox">
            <Setter Property="Background" Value="Red" />
            <Setter Property="FontSize" Value="24" />
        </Style>
    </controls:AutoCompleteBox.TextBoxStyle>
</controls:AutoCompleteBox>

 
You can use your own rich data objects.

If you shove a collection of Airport objects into the control, your business logic can work with the AutoCompleteBox's "SelectedItem" value. Talk about easy.


 
AutoComplete with a text list is so 1999.

We're opening the door for auto complete like you've never experienced it before. The drop down inside AutoCompleteBox ships with ListBox. But with a little effort building an adapter, you can easily throw in a media control, TreeView, DataGrid, you name it.

And don't worry. We made sure to master the text list scenario, too. It just works.

 
This is a preview control. Talk to us.

The Preview quality band covers controls that are useful, should meet most applications' needs, and is going to just keep getting better.

That is a good thing: we really want to hear your feedback. Your feedback is going to make a difference in the direction and the core scenarios that AutoCompleteBox covers. What sucks? What's missing? What rocks?

Check out the Silverlight Toolkit today.
Experience the live toolkit sample page.