El Matheo
El Matheo

Reputation: 1

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!

Upvotes: 0

Views: 362

Answers (2)

zoolog
zoolog

Reputation: 1

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

Upvotes: 0

Ribaz
Ribaz

Reputation: 676

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.

Upvotes: 0

Related Questions