-
Apr 13th, 2019, 07:28 PM
#1
Thread Starter
Addicted Member
[RESOLVED] Prevent user actions queuing-up while application is busy in WPF
I have converted following vb.net codes from this link: https://stackoverflow.com/questions/...cation-is-busy
ViewModel:
Code:
Class MainWindow
Private _appIdle As Boolean = True
Private Sub Hooks_OperationStarted(ByVal sender As Object, ByVal e As Windows.Threading.DispatcherHookEventArgs)
ApplicationIdle = False
End Sub
Private Sub Hooks_OperationCompleted(ByVal sender As Object, ByVal e As Windows.Threading.DispatcherHookEventArgs)
ApplicationIdle = True
End Sub
Public Property ApplicationIdle As Boolean
Get
Return _appIdle
End Get
Set(ByVal value As Boolean)
_appIdle = value
RaisePropertyChanged("ApplicationIdle")
End Set
End Property
Public Sub MainWindowViewModel()
Application.Current.Dispatcher.Hooks.OperationStarted += AddressOf Hooks_OperationStarted
Application.Current.Dispatcher.Hooks.OperationCompleted += AddressOf Hooks_OperationCompleted
End Sub
End Class
MainWindow xaml:
Code:
IsHitTestVisible="{Binding ApplicationIdle}"
But I come across some errors as you can see in this picture: https://prnt.sc/nbn55h
Please tell me how can I solve that errros?
Note: I am using .NET 4.5
Supporting link:
https://jeremybytes.blogspot.com/201...tychanged.html
Last edited by Kram Kramer; Apr 14th, 2019 at 08:54 AM.
-
Apr 14th, 2019, 07:49 AM
#2
Thread Starter
Addicted Member
Re: Prevent user actions queuing-up while application is busy in WPF
-
Apr 14th, 2019, 08:34 AM
#3
Re: Prevent user actions queuing-up while application is busy in WPF
VB uses the AddHandler command instead of C#'s += syntax to connect event handlers.
-
Apr 14th, 2019, 08:49 AM
#4
Thread Starter
Addicted Member
Re: Prevent user actions queuing-up while application is busy in WPF
Following codes solve my problem thanks to PlausiblyDamp.
Code:
AddHandler Application.Current.Dispatcher.Hooks.OperationStarted, AddressOf Hooks_OperationStarted
AddHandler Application.Current.Dispatcher.Hooks.OperationCompleted, AddressOf Hooks_OperationCompleted
Now how to solve last error:
'RaisePropertyChanged' is not declared. It may be inaccessible due to its protection level.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|