IBlog<Johan>

This and that in a developer's life in general

News

Follow johandanforth on Twitter

Random Links

Walkthroughs and Tutorials

Silverlight AutoCompleteBox DataTemplate

This is more a note for myself how to do this. The Silverlight 4 SDK contains a pretty good AutoCompleteBox that you can use. Download/install the SDK and and the control will be available in your Silverlight Controls Toolbox.

If you try to use this with RIA Services, you may notice it is displaying the Id/Key in the dropdown, but you yourself want to show a name or description. In that case you have to add a DataTemplate section to the AutoCompleteBox:

<sdk:AutoCompleteBox x:Name="FilterTextBox"
                       FilterMode="Contains"
                       MaxDropDownHeight="150"
ItemsSource="{Binding Data, ElementName=dds}"
                       ValueMemberBinding="{Binding Name}">
    <sdk:AutoCompleteBox.ItemTemplate>
        <DataTemplate>
            <TextBlock Text="{Binding Name}" />
        </DataTemplate>
    </sdk:AutoCompleteBox.ItemTemplate>
</sdk:AutoCompleteBox>

That should do it.

Posted: Sep 22 2010, 04:57 PM by jdanforth | with 2 comment(s)
Filed under:

Comments

No Comments