AutoCompleteBox: The 5 things you need to know

 
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.

Share and Enjoy:
  • Live
  • Digg
  • DotNetKicks
  • Technorati
  • del.icio.us
  • Facebook
  • Print
  • Google Bookmarks

Comments

  1. October 31st, 2008 | 11:56 pm

    [...] Jeff Wilcox and the AutoCompleteBox: The 5 things you need to know [...]

  2. JCraven
    November 2nd, 2008 | 8:13 pm

    Any Interest in actually showing how to do any of the things you list as need to know? There is absolutely no support on how the AutoCompleteBox outside of the sample that ships with the control kit. Saying that things are possible without saying how is pointless.

  3. November 2nd, 2008 | 8:18 pm

    @JCraven,
    Expect to hear more in the coming week. This post was more of a “teaser” before the guide and other planned posts came online.

  4. Manish Bharti
    December 3rd, 2008 | 1:21 am

    Do we have UI Automation support for AutoCompleteBox? I used AutomationProperties.AutomationId=”AutoCompleteBox_ID1″ but its not detected by UISpy.
    If Yes please provide me the steps.

  5. December 3rd, 2008 | 8:45 am

    @Manish,
    UI automation support was added for the December Toolkit release and will be available in the coming weeks.