3

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?

sourcenouveau
  • 29,356
  • 35
  • 146
  • 243

1 Answers1

3

Set the e.Handled to true in the handler.

EDIT

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

Kenan E. K.
  • 13,955
  • 3
  • 43
  • 48
  • I'm using the Composite Application Library and the problem seems to stem from using EventAggregator to publish an event in the SelectedItemChaged event handler. – sourcenouveau Jul 15 '09 at 12:52
  • Turns out the problem is from some of my other code that was triggering the event... the above answer is still valid for the question in general. – sourcenouveau Jul 15 '09 at 15:33
  • It still bubbles for me as well, and also, your blog link is dead. – dcp May 08 '15 at 15:12
  • It seems this is a framework issue. I have updated the changed link. – Kenan E. K. May 12 '15 at 19:46