I want to save the "view" status of my wpf application using the Telerik's PersistenceFramework.

I can save and load the stream on-the-fly, like in the docs examples, but I need to store the status stream object on database.

I'm currently trying with no luck those functions:

public static void SaveGridStatus(System.IO.Stream stream) { using (MyEntities context = new MyEntities()) { MemoryStream ms = new MemoryStream(); stream.CopyTo(ms); TestViewStatus t = new TestViewStatus { GridStatus = ms.ToArray() }; context.TestViewStatuses.Add(t); context.SaveChanges(); } } public static Stream LoadGridStatus() { using (MyEntities context = new MyEntities()) { TestViewStatus t = (from d in context.TestViewStatuses select d).FirstOrDefault(); return t.GridStatus; } }

where TestViewStatus.GridStatus is a VARBINARY(MAX)

Something is saved in the database, but when I try to load it in my control using the persistence framework nothing happens

edit:

code to load stream into control, as requested

private void SaveGridLayout_Click(object sender, System.Windows.RoutedEventArgs e) { PersistenceManager manager = new PersistenceManager(); this.stream = manager.Save(this.BrowseProjectGrid); SaveBrowseGridStatus(this.stream); this.EnsureLoadState(); } private void LoadGridLayout_Click(object sender, System.Windows.RoutedEventArgs e) { this.stream.Position = 0L; PersistenceManager manager = new PersistenceManager(); manager.Load(this.BrowseProjectGrid, LoadBrowseGridStatus()); this.EnsureLoadState(); }