简体   繁体   中英

How to disable mouse buttons in C# WPF?

During big files loading I want to disable mouse buttons to unable user to click on UI elements and triggers events.

Edit When I am loading big size file in my WPF Caliburn Micro application I changed IsEnabled property of Listbox to false, because I want to disable a button during this process. Next when file is loaded I changed IsEnabled property of Listbox to true. After that every click on disabled button raised events and I did not want that. I don't know how to remove this events, and where there are stored, so i thought that the easier way to solve this problem is to disable mouse buttons during file loading process. But it is also not easy... Thank You in advance!

If you only want to disable mouse buttons, the user can still use the keyboard. So you need a different technique. You can add a hidden Gird with Opacity="0.5" to your window. When you want to prevent the user from using the window, just call visible the grid.

What about overriding SelectionChanged event on ListBox and setting it to Handled = true when loading big data?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM