This question is locked. New answers and comments are not allowed.
I have implemented a CustomePropertyProvider for my TileView and I am attepting to save and restore the positions of the tiles at the moment. I can save the Positions and write these to isolated storage. However when I read these back the manage does not seem to be firing the RestoreValue Method on my class, but it did call the ProvideValue Method when saving.
Class Implementing ICustomPropertyProvider
Code for Saving:-
Code for Loading
This is called from the Constrctor of the userControl
Any help would be appreciated as I get no errors.Thanks
Greg
Class Implementing ICustomPropertyProvider
publicclassTileViewCustomPropertyProvider : ICustomPropertyProvider{publicCustomPropertyInfo[] GetCustomProperties(){returnnewCustomPropertyInfo[]{newCustomPropertyInfo("Layout",typeof(Dictionary<string,int>))};}publicvoidInitializeObject(objectcontext){}publicobjectInitializeValue(CustomPropertyInfo customPropertyInfo,objectcontext){returnnull;}publicobjectProvideValue(CustomPropertyInfo customPropertyInfo,objectcontext){RadTileView tileView = contextasRadTileView;if(customPropertyInfo.Name =="Layout"){Dictionary<string,int> positions =newDictionary<string,int>();foreach(RadTileViewItem tileintileView.Items){positions.Add(tile.Name, tile.Position);}returnpositions;}returnnull;}publicvoidRestoreValue(CustomPropertyInfo customPropertyInfo,objectcontext,objectvalue){RadTileView tileView = contextasRadTileView;Dictionary<string,int> positions = valueasDictionary<string,int>;if(customPropertyInfo.Name =="layout"){foreach(RadTileViewItem tileintileView.Items){intposition = -1;if(positions.TryGetValue(tile.Name,outposition))tile.Position = position;}}}
Code for Saving:-
PersistenceManager manager = new PersistenceManager(); stream = manager.Save(this.rtvDashboard); using (var store = IsolatedStorageFile.GetUserStoreForApplication()) { var fs = store.CreateFile("dashboardLayout"); byte[] bytes = new byte[stream.Length]; fs.Write(bytes, 0, (int)stream.Length); }Code for Loading
private void LoadSettings() { PersistenceManager manager = new PersistenceManager(); using (var store = IsolatedStorageFile.GetUserStoreForApplication()) { if (store.FileExists("dashboardlayout")) { var fs = store.OpenFile("dashboardLayout", FileMode.Open); fs.Position = 0L; manager.Load(this.rtvDashboard, fs); } } }public MainPage() { InitializeComponent(); this.btnSaveLayout.Click += new RoutedEventHandler(btnSaveLayout_Click); ServiceProvider.RegisterPersistenceProvider<ICustomPropertyProvider>(typeof(RadTileView), new TileViewCustomPropertyProvider()); LoadSettings(); }Any help would be appreciated as I get no errors.Thanks
Greg