IsolatedStorageProvider isoProvider = new IsolatedStorageProvider();
isoProvider.SaveToStorage();
isoProvider.LoadFromStorage();
using System.Windows;
using System.Windows.Controls;
using Telerik.Windows.Persistence.Storage;
namespace PersitentSettingDemo
{
public partial class MainPage : UserControl
{
IsolatedStorageProvider isoProvider = new IsolatedStorageProvider();
public MainPage()
{
InitializeComponent();
}
private void RadButton_Click(object sender, RoutedEventArgs e)
{
isoProvider.SaveToStorage();
}
private void RadButton_Click_1(object sender, RoutedEventArgs e)
{
isoProvider.LoadFromStorage();
}
}
}
To test click on the Save Settings
button, then refresh the page & notice that all controls have restored
to their default values.
Now click on the Restore Settings
button & notice again that all user settings are now populated again.
On a side note if you want to save the
user settings for all your controls in a container then just attach the
StorageId property to that container control instead.
For example, I could have achieved the
same result by adding
<Grid x:Name="LayoutRoot" telerik:PersistenceManager.StorageId="mygridContainer">
& removing the storage ID from all
individual controls.
On another side note & an important
one; The StorageId could be any arbitrary unique string that the
Framework can use to identify the control uniquely.
More details on it here:
http://www.telerik.com/help/silverlight/persistence-framework-getting-started.html
As far as I know, it has to be unique
for every instance of IsolatedStorageProvider but I will leave that test
to another blog post.
I will also need to figure out how
this behaves in a multiuser scenario. Will write as soon as I have more
information about it.
For Now use this simple technique & nJoy Coding. P.S. Attached the demo project for your reference.