开发者

Silverlight AutoCompleteComboBox - build list asyncronously?

I would like to have a textbox in a Silverlight app where the user can type in it, and after a few characters are entered the control calls a web service to retrieve a list of potential choices that the user can choose from. Essentially it is a type-ahead combobox but I don't want to keep all of the possible choices in memory I want to load them dynamically after getting some input from the user. I'm hoping that the AutoCompleteComboBox from the Silverlight Toolkit can provide this functionality, but all of the examples I can find use a static list that is kept fully in m开发者_StackOverflowemory.

Can the AutoCompleteComboBox do this? If so, how? If not, what are my other options?


I ended up figuring this out based on their samples page, though it was far from obvious. You put an event handler on the Populating event of the AutoCompleteTextBox. Inside the handler you set e.Cancel = true and then fire off an async event. When the async event completes you set the ItemsSource of the AutoCompleteTextBox and then call its PopulateComplete() method. Seems to work but I haven't extensively tested it.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜