views:

648

answers:

1

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?

+2  A: 

Set the e.Handled to true in the handler.

kek444
I have tried this and it still bubbles.
emddudley
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.
emddudley
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.
emddudley