Preventing WPF TreeView's SelectedItemChanged event from bubbling

青春壹個敷衍的年華 提交于 2019-12-02 01:25:32

问题


I have a WPF TreeView which triggers a SelectedItemChanged event. Whenever I select an item in the TreeView, the SelectedItemChanged event is triggered for the selected item and all of the selected node's ancestors in the tree.

How do I prevent the SelectedItemChanged event from firing more than once?


回答1:


Set the e.Handled to true in the handler.

EDIT

As an update to this subject, view this blog post.



来源:https://stackoverflow.com/questions/1127614/preventing-wpf-treeviews-selecteditemchanged-event-from-bubbling

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