Reputation: 2458
I have a c# Application where I call a user control
with a click event
. This user control
provides the authentication to a MySQL database.
I dont want them to be able to use any of the other controls if they did not authenticate.
How can I make the rest of the Application aware that this user is authenticated. Can I somehow set a property in the main window ?
Upvotes: 2
Views: 119
Reputation: 171246
You can put everything that should not be accessible inside of an invisible Panel and disable it. This will also disable all children.
Upvotes: 1
Reputation: 45106
Consider a separate logon page and not allow them access to the application Page / Window at all until there is a successful logon. In the constructor of the other pages just block them if the user is not authenticated. I have not used MemebershipServices in WPF but in ASP.NET it is clean with page level authority based on authenticated and even by Role. You can use App.cs for your global variables / properties.
Upvotes: 1
Reputation: 6553
You could bind
the IsEnabled
(or similar) properties of the controls to an IsAuthenticated
Property of the Window / ViewModel. This would be the simplest because then you don't have to manually set the properties and just set the IsAuthenticated
value to true / false.
The other option would be to manually set all of the IsEnabled to true / false depending on if authentication worked.
Upvotes: 1