KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
I've been trying to get my WPF application to prompt users to either discard their unsaved changes or to cancel when they navigate using a TreeView. How can I cancel a user’s WPF TreeView click? How do I properly handle a PreviewMouseDown event with a MessageBox confirmation? I think I've found a bug. The MessageBox does not play nice with PreviewMouseDown. It seems to "handle" a click regardless of how its e.Handled is set if there's a MessageBox shown. For this XAML... <TreeView Name="TreeViewThings" ... PreviewMouseDown="TreeViewThings_PreviewMouseDown" TreeViewItem.Expanded="TreeViewThings_Expanded" TreeViewItem.Selected="TreeViewThings_Selected" > ...compare these alternative methods... Sub TreeViewNodes_PreviewMouseDown(...) e.Handled = False End Sub Sub TreeViewNodes_PreviewMouseDown(...) MessageBox.Show("Test", "Test", MessageBoxButton.OK) e.Handled = False End Sub These two methods behave differently. Without the MessageBox, TreeViewNodes_Selected() or TreeViewThings_Expanded() will execute. With the MessageBox, they won't. Is this a bug or is there something going on here that I should understand?
Tags (comma-separated)
Save Edits
Cancel