- Obtain and Build the Code
- Setting Up a Project
Caliburn supplies an interface, IStateManager, and two implementations: IsolatedStorageStateManager and DeepLinkStateManager. The purpose of these classes is to give you a simple key/value persistent state mechanism. It is intended for very simple scenarios.
For example, the IsolatedStorageStateManager might be used to persist a window's size and position across application starts or the DeepLinkStateManager might be used to represent the current state of the application as a URL.
The IStateManager allows you to insert, update, get and remove values from the state. You must call CommitChanges before the state will be pushed to its underlying store. Before the commit, the BeforeStateCommit event will fire. Whenever the state is loaded,
either by a call to Initialize, or in the case of DeepLinkStateManager by the browser's url changing, the AfterStateLoad event will fire.
The IsolatedStorageStateManager serializes its key/value pairs as XML and stores them using IsolatedStorageFile.GetUserStoreForApplication(). When calling Initialize or CommitChanges, you should supply the name of the file you wish to read from or commit to.
The DeepLinkStateManager converts its key/value pairs into querystring parameters. When calling CommitChanges, you should supply the name you wish the browser to display for the history point. You may pass a default name into Initialize, but this is not necessary.
It should be noted that the current implementation has a runtime dependency on the ASP.NET ScriptManager. Thus, to create a Sivlerlight application which makes uses of this feature, you must include the following markup in the .aspx page that hosts your Silverlight
<asp:ScriptManager ID="ScriptManager1" runat="server" EnableHistory="true" EnableSecureHistoryState="false"></asp:ScriptManager>
A secondary requirement is that the Silverlight object tag needs an ID attribute with a value, eg:
<object data="data:application/x-silverlight-2," type="application/x-silverlight-2" width="100%" height="100%" id="host">