views:

31

answers:

2

How can i block access to all silverlight pages if user is not logged in, without writing verification code in each page?

A: 

I might be way off, but isn't that where inheritance and base class concept come in handy?

Your question seems to be a bit too vague.

danijels
+2  A: 

All views can have multiple states added (e.g. simple buttons have lots of states).

Add 2 states to your outer shell view. e.g. A LoggedIn state and a LoggedOut state.

  • The LoggedIn state shows your normal content view (as a child control)
  • The LoggedOut state only shows the login control.

Then use the VisualStateManager to switch between states based on the login state changes. An added bonus with this technique is you can author your own transitions from one state to the other (I strongly recommend using Expression Blend for this type of work).

This way they cannot get at anything and, as a bonus, you can login/logout from anywhere in your app and not lose your place :)

If you are using an MVVM model, you can use an attached property to control the state changes.

If you need specific help, or example, just ask.

Enough already