views:

912

answers:

1

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 J-O-H-N, a list containing John will appear and they can select John as needed. As they move on to typing S-M-I-T-H, 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 custome 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

+1  A: 

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.

mattmanser
I have considered storing the pre-pend data in a property in my Model-View, which will accomplish what you're saying, but it seems to be a cludgy way to accomplish the task. I may do it as a short-term solution, but I hope it doesn't have to be the final. Just doesn't seem very clean to me.
Steve Brouillard
So, in the end, this is what I have decided to do. The only other option at this point is to write my own version of a Selection Adapter to change this behavior. Might be interesting later, but not with a deadline.
Steve Brouillard