public void Serialization() { var viewmodel = new Viewmodel(); Stream stream = new MemoryStream(); var writer = XmlDictionaryWriter.CreateDictionaryWriter(XmlWriter.Create(stream)); var serializer = new DataContractSerializer(typeof(Viewmodel)); serializer.WriteObject(writer, viewmodel); }
protected override void OnNavigatedTo(NavigationEventArgs e) { Debug.WriteLine("MainPage.OnNavigatedTo"); if (State.ContainsKey(ModelKey)) { Debug.WriteLine(" Load State"); var viewModel = State[ModelKey]; DataContext = viewModel; } else { Debug.WriteLine(" New State"); DataContext = new Viewmodel(); } base.OnNavigatedTo(e); }