I have a TreeView that when selected drives the view, by selecting one item a specific view is displayed and by selecting another item a different view is displayed. When the selection is made the user is able to make changes to the data and the model then needs to be saved at a later point in time (when the tree selection changes to another item). The code I am using to display a message and to save the data are both awaitable functions and require the use of the async keyword, to rewrite either of these functions to a non-async method is not an option. I was hoping that I could use the SelectionChanging event because of the ability to cancel the selection if the user decided they really did not want to change to another selection.
I have changed the test program to simulate the issue, the top tree view is handling the SelectionChanging event asynchronously. When the user click on a tree view item a message box is displayed the selection is made before the message box is dismissed and the cancel is not recognized. The bottom tree view handles the SelectionChanging event synchronously and works as expected.
Thanks,
Justin
Attachment:
TreeViewTesting_New_79dab325.zip