1

我正在尝试让自己成为一个 AutoCompleteTextBox,当输入它时会在下拉列表中显示建议。

通过从头开始编写一个新的用户控件,我设法让这个工作(有一些小问题)。

然而,经过一番阅读,似乎不推荐这种“重新发明轮子”的方法,它让我觉得我拥有的功能非常接近组合框,它有一个文本框而不是切换按钮。

有什么方法可以扩展 ComboBox,稍微更改它的模板并允许我编写一些方法来根据输入的文本填充下拉项?

4

2 回答 2

3

Reinventing the wheel is risky, but then again an AutoCompleteTextBox is logically not the same as a ComboBox. You might for example want to provide some callbacks to provide autocomplete items to the text box based on text entered instead of providing a single ItemsSource of all options possible. Also ComboBox displays all items in the ItemsSource and you would not have enough control to filter or reorder them. You could however look for existing solutions to this problem. There is one here for example. I have not tested it but Hermit Dave is known in the developer community, so it should be a good base for whatever you need. You could make changes to this control and contribute to the development and that would not be reinventing the wheel.

于 2012-08-07T16:05:20.267 回答
2

在实际应用程序中只有一种可接受的自动完成方法:http: //blog.petegoo.com/index.php/2011/11/22/building-an-auto-complete-control-with-reactive-extensions-rx /

我再严肃不过了。

于 2012-08-09T17:45:12.073 回答