IsolatedStorageProvider isoProvider =
new
IsolatedStorageProvider();
isoProvider.SaveToStorage();
Here is my test application: http://dl.dropbox.com/u/15525269/TelerikPersistence.zip
Am I using the telerik:PersistenceManager.StorageId attribute incorrectly?
15 Answers, 1 is accepted
Thank you for providing this project. To be persisted, the RadDocking control needs a custom property provider, which you can find an example with in our online demos here. After registering this provider, you will be able to save and load the layout and the contents of the panes of the docking control correctly. Please let me know if you have questions on this.
Best wishes,
Alex Fidanov
the Telerik team
Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get now >>
Currently, the GridView and Docking controls only have implemented custom property providers, which you can find in the online demos. They are more complex than the rest of the controls and they need custom serialization.
Please note that you can implement and register your own custom providers for any control (or other custom controls), if you need to customize or plug into the serialization process of the PersistenceFramework.
Greetings,
Alex Fidanov
the Telerik team
Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get now >>
Edit. The following seems to work (loads users layout on page load, allows them to save layout with button). Is there a better way?
public
SomeView()
{
InitializeComponent();
ServiceProvider.RegisterPersistenceProvider<ICustomPropertyProvider>(
typeof
(RadGridView),
new
GridViewCustomPropertyProvider());
LoadDefaultView();
}
private
void
SaveViewButtonClick(
object
sender, RoutedEventArgs e)
{
var manager =
new
PersistenceManager();
this
._stream = manager.Save(
this
.SomeGridView);
var reader =
new
StreamReader(_stream);
string
text = reader.ReadToEnd();
SaveIsoData(text,
"SomeGridView"
);
MessageBox.Show(
"Layout saved."
);
}
private
static
void
SaveIsoData(
string
data,
string
fileName)
{
using
(IsolatedStorageFile isf = IsolatedStorageFile.GetUserStoreForApplication())
{
using
(var isfs =
new
IsolatedStorageFileStream(fileName, FileMode.Create, isf))
{
using
(var sw =
new
StreamWriter(isfs))
{
sw.Write(data);
sw.Close();
}
}
}
}
private
void
LoadDefaultView()
{
var manager =
new
PersistenceManager();
byte
[] byteArray = Encoding.UTF8.GetBytes(LoadIsoData(
"SomeGridView"
));
Stream stream =
new
MemoryStream(byteArray);
stream.Position = 0L;
manager.Load(
this
.SomeGridView, stream);
}
private
static
string
LoadIsoData(
string
fileName)
{
string
data = String.Empty;
using
(IsolatedStorageFile isf = IsolatedStorageFile.GetUserStoreForApplication())
{
using
(var isfs =
new
IsolatedStorageFileStream(fileName, FileMode.Open, isf))
{
using
(var sr =
new
StreamReader(isfs))
{
string
lineOfData = String.Empty;
while
((lineOfData = sr.ReadLine()) !=
null
)
data += lineOfData;
}
}
}
return
data;
}
Have you looked at the IsolatedStorageProvider class that provides this functionality out of the box?
Kind regards,
Alex Fidanov
the Telerik team
Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>
The IsolatedStorageProvider internally uses a PersistenceManager instance, so whatever you can do with the persistence manager class, the isolated storage provider can do as well. What it does is just to save the serialization stream in the isolated storage.
All the best,
Alex Fidanov
the Telerik team
Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>
After few hours, it'not able to use PF and RadGridView in a normal context (save and load automatically).
Can you provide me a full complete example with PF AND RadGridView using IsolatedStorage (not STREAM). More, with no buttons LOAD and SAVE because I don't want my users push some kind of button to save and load. I need to load the PF when the silverlight page appear on the screen and save when the user go to another page.
The demo don't show any information.
I attached a sample project to get you started on your task. Please examine it and let us know if it works for you.
Also, please keep in mind that the data saved in the isolated storage, should be loaded only after the RadGridView.Columns are generated.
Best wishes,
Tina Stancheva
the Telerik team
Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>
how can i make it to work on childwindow loaded and closed.rather to work on application start and exit.
best regards
shabbir
with regards
shab
I am not sure why you have troubles integrating our code into your solution. Can you please elaborate more on the issues you've encountered? Are there any exceptions raised?
In the meantime I attached a modified version of the sample application, where the RadGridView is hosted in a ChildWindow and the Persistence framework save the UI settings of the GridView when the ChildWindow is closed and loads them again when the RadGridView is loaded. I hope this solution will help.
Kind regards,
Tina Stancheva
the Telerik team
Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>
I have downloaded a trial and have noticed that when I use
IsolatedStorageProvider isoProvider = new IsolatedStorageProvider();
isoProvider.SaveToStorage();
and then the next session do a Load
IsolatedStorageProvider iso = new IsolatedStorageProvider();
iso.LoadFromStorage();
the layout is nicely restored. However: some of the grid columns are dropdown lists and databound. When I have done the LoadFromStorage the databinding of the viewmodel is gone, and the list is empty. Also recreating the viewmodel does not work.
Figured it out myself. Registering the ICustomPropertyProvider helps a lot :-)