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

Twitter Trackbacks for Silverlight AutoCompleteBox DataTemplate - IBlog<Johan> [asp.net] on Topsy.com said:

Pingback from  Twitter Trackbacks for                 Silverlight AutoCompleteBox DataTemplate - IBlog&lt;Johan&gt;         [asp.net]        on Topsy.com

# September 29, 2010 12:23 AM

JohanLover said:

Johan, I love you, I spend a whole day digging around, trying to make this work, no go, then I read your post and it worked!!!!

# October 14, 2010 10:25 AM