简体   繁体   中英

Appending Silverlight Toolkit AutoCompleteBox with selected item

I'm working with an Autocomplete box from the Silverlight Tookit (December release). As the user types, I use a webservice to return an ItemsSource containing a lookup of only the word that the user is currently typing into the AutoCompleteBox (as oppossed to the entire phrase, which is the default behavior). What I'd now like to do is if the user selects an option from the dropdown, I'd like to APPEND that option to the AutoComplteBox, NOT replace it as is happening now.

For example, if the final item should read as "John Smith". Currently, as the user types JOHN, a list containing John will appear and they can select John as needed. As they move on to typing SMITH, I've handled the Populating Event to pass only the final word in the .Text property to the Web Service and they will get a list that includes smith. So far, so good. However, when "Smith"is selected from the DropDown, the Contents "John" are REPLACED by the contents "Smith", leaving you with simply "Smith", not "John Smith" as we'd like.

I've attempted to deal with this by writing custom handlers for the DropDownClosing and/or SelectionChanged events. Neither of these appears to be the correct event to handle.

Can someone direct me where I might go to manage this behaviour?

Thanks

Seeing as you're already attaching to the on populating event and presumably kicking off requst to the server for the data, why not just append the 'John ' to all the items in the itemssource before you give it back? Then when you match it'll already be there.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM