开发者

wpf - autocompletebox doesn't update on mousedown

I have an autocompletebox that works but for one oddity I was hoping for help with. When selecting an item in the popup, using the keyboard to arrow down and then selecting it using either the enter key or with the mouse, the item is selected and updated into the autocompletebox. However, if one instead of arrowing down to the item simply hovers over it instead and select it with the mouse, the selecteditem is set correctly but the autocompletebox doesn't get updated with the selecteditem.

That is, arrow down and select an item and the autocompletebox reflects the selected item whereas just hovering over and selecting the item means the autocompletebox does not reflect the selection - instead it shows what the user typed into the box; not开发者_如何学编程e that the backing property is aware of the selected item so it does work either way, only it's not reflected in the textbox.

Any help is appreciated. Thanks

I should add that it is OnSelectedItemChanged that doesn't seem to get called...


This issue is explained here: http://www.siimviikman.com/2012/05/30/wpf-autocompleteboxfiltering-similar-items/

As precised in the end of the article, the user cannot navigate through items (with arrow keys + hit TAB). That is why I could not use their solution.

In the WPF Toolkit source code (UpdateTextCompletion method), one can read:

// Perform an exact string lookup for the text. This is a 
// design change from the original Toolkit release when the 
// IsTextCompletionEnabled property behaved just like the 
// WPF ComboBox's IsTextSearchEnabled property.
//
// This change provides the behavior that most people expect
// to find: a lookup for the value is always performed.
newSelectedItem = TryGetMatch(text, _view, AutoCompleteSearch.GetFilter(AutoCompleteFilterMode.EqualsCaseSensitive));

So I simply patched the WPF Toolkit and commented out the calls to UpdateTextCompletion method, both in OnAdapterSelectionComplete and OnAdapterSelectionCanceled.

As I don't use text completion, this fix seems to work fine.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜