Using StorageHandler in ViewModel

Topics: Framework Services
Aug 16, 2011 at 5:21 PM

I have a page, MyPage, with a corresponding VM, MyPageViewModel, that has MyProperty.  I created the following  StorageHandler to save state across app invokes:

 

    public class MyPageStorage : StorageHandler<MyPageViewModel>

    {

        public override void Configure()

        {

            Property(x => x.MyProperty)

                .InAppSettings();

               

        }

    }

 

MyPage is navigated to from HomePage and I want the value of MyPage to be saved in the same AppSettings location whenever the user navigates away from MyPage.  Is there a way to accomplish this using the same instance of MyPageStorage injected into MyPageViewModel and called in the OnDeactivate method?  Or is there a better way?