WPF Editable Combobox IsFocused problem

若如初见. 提交于 2019-12-23 08:50:06

问题


I am developing a Watermarked ComboBox by modifying the ComboBox ControlTemplate. Everything is fine when the ComboBox is not in an editable mode, but when I change the edit mode to True, the IsFocused property is never set to True. This is because in edit mode, the ComboBox is using a TextBox. This is an exact copy of this StackOverflow question: . There are no responses to that question.

Please drop a line if you know how to solve this, or please point me to links that provide a Watermark ComboBox implementation. Thanks, Rey.


回答1:


You could try to use the IsKeyboardFocused or IsKeyboardFocusWithin instead




回答2:


Try using the IsFocused or IsKeyboardFocused or IsKeyboardFocusWithin properties of the TextBox control which is within the ComboBox control. The TextBox can be found at e.OriginalSource(TextChangedEventArgs property).

It worked for me.



来源:https://stackoverflow.com/questions/1911307/wpf-editable-combobox-isfocused-problem

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!