Saturday, September 1, 2012

How to maintain state in a Silverlight 5 application?

How to maintain state in a Silverlight 5 application?

I am new to Silverlight. I got a login page and after the user logs in I want to maintain the username and details within the application.

How to achieve this?

Answers & Comments...

Answer: 1

Use cookies.

  1. Silverlight Tip of the Day #18: How to Set Browser Cookies.
  2. How to: Get and Set Cookies.
by : Dennishttp://stackoverflow.com/users/580053

Answer: 2

You could use Key/Value Pairs with the IsolatedStorageSettings class

by : user1592890http://stackoverflow.com/users/1592890

Answer: 3

Use a global context object that can be accessed from any of the Silverlight view models e.g.

public class ApplicationContext {         // Static instance of the application class.         private static ApplicationContext _instance;          public static ApplicationContext Instance()         {             return _instance ?? (_instance = new ApplicationContext()         }          public UserDetailsCustomClass SecurityContext { get; set; } } 

and then it can be used anywhere within the Silverlight app e.g

  var submUserLogin = ApplicationContext.Instance().SecurityContext.CurrentUser.Login; 
by : Myles Jhttp://stackoverflow.com/users/236573




No comments:

Post a Comment

Send us your comment related to the topic mentioned on the blog