Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Wpf stop routing event when MessageBox appear?

I've PreviewMouseDown event on TreeView in order to determine if user can select other item based on some logic. If the current item data changed, will appear MessageBox that asks the user if he want to discard the changes. if user press YES , I set e.Handled = false; to enable the new selection. and if user press NO, I set e.Handled = true; to cancel the new selection.

The problem is that although I set e.Handled = false , the event stop and no selection event occurs on TreeView. Someone has solution for that?

Thanks in advance!

like image 903
yossharel Avatar asked Oct 13 '22 18:10

yossharel


1 Answers

The focus change to the message box cancels the mouse down event so it doesn't matter whether it is handled or not. Since you know which item the user was trying to select before you displayed the message box, simply select that item programmatically if the user presses YES.

like image 73
Rick Sladkey Avatar answered Oct 18 '22 01:10

Rick Sladkey