silverlight中的IsolatedStorageSettings是一个独立存储空间,可以通过它来实现数据的存储于交互,如实现页面传值。使用前要先引入命名空间:using System.IO.IsolatedStorage;
/// <summary>
/// 声明独立存储
/// </summary>
private IsolatedStorageSettings appSettings = IsolatedStorageSettings.ApplicationSettings;
/// <summary> /// 将信息加入存储区 /// </summary> public void SetLineInfo() { if (!appSettings.Contains("RowNumber")) { appSettings.Add("RowNumber", txtWallRowNumb.Text.Trim()); } if (!appSettings.Contains("ColNumber")) { appSettings.Add("ColNumber", txtWallColNumb.Text.Trim()); } }
调用独立存储区中的值:
if (appSettings.Contains("RowNumber")) { RowNumber = Convert.ToInt32(appSettings["RowNumber"]); }
清空独立存储区:
appSettings.Clear();