Over a million developers have joined DZone.
{{announcement.body}}
{{announcement.title}}

Tips and tricks : Silverlight autocompletebox with huge amount of data

DZone's Guide to

Tips and tricks : Silverlight autocompletebox with huge amount of data

·
Free Resource
Online version is at : http://www.alphablog.org/2011/12/11/tips-and-tricks-silverlight-autocompletebox-with-huge-amount-of-data/
This new post will explain the ability to use the autocomplete box with more than 10 000 items in the list. It will result an unpleasant latency... It will freeze your user interface during seconds !

The silverlight solution

You just need to add the System.Windows.Control reference.



The main page Xaml is like described below :


Generate items


Here is the little code that generate 12 000 lines and put it to the itemsource :



You can run the sample at this time. There is a 10 sec latency (dependant to your computer power)...



Solve the problem


We will use blend to speed up development and show the simplest way to produce this solution.

At this time you need to edit the general template (Edit a copy, not create a blank one) :



And edit the "ItemPanel" of your selector :



You must replace the "StackPanel" with a VirtualizingStackPanel:

  --> 

At this point you mzy think you have finished but, if you run your solution, you will see it remains the latency.

Final tips

The tricky trick is to add a MaxHeight that force the system to generate a maximum of 250px of ItemTemplate


Sources

Sources are available here

Topics:

Opinions expressed by DZone contributors are their own.

THE DZONE NEWSLETTER

Dev Resources & Solutions Straight to Your Inbox

Thanks for subscribing!

Awesome! Check your inbox to verify your email so you can start receiving the latest in tech news and resources.

X

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}