Text Searching in Silverlight 5 ComboBox and ListBox

Do you know that, we can now search text present in ComboBox and ListBox? This feature was not available in earlier version of Silverlight. To implement it, we had to write custom behavior. Now if you are using Silverlight 5, you can easily use this feature without writing any piece of code.


In this Tip we will discuss about it. We don't have to add any extra code, because it is now the default behavior of those control. Read to know more.



This post is a small tips & tricks to let you know that, you can find the behavior of searching in-built in your ComboBox and ListBox control. To see a demo of it, create a Silverlight Project and add one ComboBox and one ListBox in the XAML page. Add some records inside them or fetch them from the service or code behind.


Now, run your application and click on the combo box to open the dropdown menu. Start typing your text. You will notice that the searched text will be highlighted to the nearest matching item. Once you select any item from the ComboBox, it will close by default. Now again try to type something (assuming the focus is still on the ComboBox control). You will see that, the item with maximum matched content has been selected in the control.


Similarly, if you do the same thing for the ListBox, you will find the same behavior in that too.


Hence, no need to write additional code to implement the feature in your Silverlight application anymore. Just add the ComboBox or ListBox depending upon your requirement and you are all set to go. Enjoy using the Text searching behavior.

If you have come this far, it means that you liked what you are reading. Why not reach little more and connect with me directly on Twitter , Facebook , Google+ and LinkedIn . I would love to hear your thoughts and opinions on my articles directly. Also, don't forget to share your views and/or feedback in the comment section below.


  1. Nice to have it in the Combo and List. Currently we are using Behavior with a huge lines of code to implement the same. This will be very useful in Silverlight 5.

  2. Don't forget that there is an AutoCompleteBox in the toolkit.

  3. @Shimmy,
    AutoCompleteBox is different than the ComboBox or ListBox. You can't use it in all cases.

  4. Can you point me to some code samples to actually get this working on Windows Phone 7 - since it is not Silverlight 5 - I want to have an idea how creating such a behavior would work

  5. Joris, I don't have code available for it but somewhere on net I saw this behavior present to download with a good explanation. Try to search on net and if you didn't get the one, let me know. I will search and share that to you.

  6. Hello Kunal, Thanks for your various post for Silverlight. It helps me lot.
    But I have one query:
    I have a form which has a ComboBox(We have to select one of value from combobox by default it shows empty). when we submit the form it doesn't show red border around combobox but it shows validation message in summery. :(
    I have other control is textbox which works fine. it shows red border at the time of validation and also shows validation message in summery.

    This is the code for text box and combobox :

    Do you have any idea ?
    your help will be highly appreciated.

  7. Do you have any solution of last comment about ComboBox validation ?

  8. Yes, I will share the code snippet to you soon.


© 2008-2016 Kunal-Chowdhury.com - Microsoft Technology Blog for developers and consumers | Designed by Kunal Chowdhury
Back to top