将 Silverlight Toolkit AutoCompleteBox 添加到所选项目

发布于 2024-07-13 23:17:43 字数 593 浏览 6 评论 0原文

我正在使用 Silverlight Tookit(12 月版本)中的自动完成框。 当用户键入时,我使用 Web 服务返回一个 ItemsSource,其中仅包含用户当前在 AutoCompleteBox 中键入的单词的查找(与整个短语相反,这是默认行为)。 我现在想做的是,如果用户从下拉列表中选择一个选项,我想将该选项附加到 AutoComplteBox,而不是像现在那样替换它。

例如,如果最后一项应读作“John Smith”。 目前,当用户键入 JOHN 时,将出现包含 John 的列表,他们可以根据需要选择 John。 当他们继续输入 SMITH 时,我已经处理了填充事件,仅将 .Text 属性中的最后一个单词传递给 Web 服务,他们将获得包含 smith 的列表。 到目前为止,一切都很好。 但是,当从下拉列表中选择“Smith”时,内容“John”将被内容“Smith”替换,只剩下“Smith”,而不是我们想要的“John Smith”。

我尝试通过为 DropDownClosing 和/或 SelectionChanged 事件编写自定义处理程序来解决这个问题。 这些似乎都不是正确处理的事件。

有人可以指导我去哪里管理这种行为吗?

谢谢

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 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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

手长情犹 2024-07-20 23:17:43

鉴于您已经附加到填充事件,并且可能开始向服务器请求数据,为什么不在将其返回之前将“John”附加到 itemssource 中的所有项目呢? 然后当你匹配时它就已经在那里了。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文