I need to enable/disable a WPF button based on the return of a method.
I have a HasPermission method that tells me if the user can or not click on that button.
I've seen that I could use Command => CanExecute to avoid the execution of the action. Seen here:
How to enable/disable a button in WPF?
My question is, I have a lot of Windows in which I'll be checking for the permission, is this the best approach? Will I really have to write from 2 to N commands for every window I have?
Is there any way to make this global?
For instance, could I create the generic commands (Search/Create/...) and then only get the window it was called from and pass it to my HasPermission method?