开发者

Silverlight page check if user is logged in

How can i block access to all silverlight pages if user is not logged in, without writing verification code i开发者_运维问答n each page?


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.


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜