0

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!

El Matheo
  • 1
  • 1
  • If it is just an individual window, you can disable the window from the code. Not sure why you would want to do this, during big files loading you can just run it as a foreground task to freeze the software. – Jay Mason Jan 27 '21 at 17:52
  • 1
    You may want to juice up your question with more details. Also see: https://stackoverflow.com/help/how-to-ask – Nat Riddle Jan 27 '21 at 17:53
  • 1
    Thanks, I will do my best in the next post. It was my first. – El Matheo Jan 28 '21 at 17:03
  • @Jay Mason Thanks, I have tried your solution. Before start of loading file I have disabled window. When file was loaded I had to enable window again and after that every of events which were raised during loading file, fired and made a lot of mess in UI. If you have other solutions you are welcome. – El Matheo Jan 28 '21 at 17:08
  • I have found solution at this post https://stackoverflow.com/questions/9527404/disabled-button-fires-events-in-wpf – El Matheo Jan 28 '21 at 18:02

2 Answers2

0

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.

Ribaz
  • 476
  • 3
  • 10
0

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

zoolog
  • 1
  • 2
  • I have tried to implement your solution, but I can't. Could you send example, how to override event in ViewModel and how to use it in View? Thank you in advance. – El Matheo Jan 28 '21 at 17:02