public DocumentDetailPage() { this.InitializeComponent(); if (!ViewModelBase.IsInDesignModeStatic) { ViewModel = new DocumentDetailViewModel(); DataContext = ViewModel; } }
protected override void SaveState(Dictionary<String, Object> pageState) { var dataTransferManager = DataTransferManager.GetForCurrentView(); dataTransferManager.DataRequested -= DataTransferManager_DataRequested; string serializedState = SerializationHelper.SerializeToString(ViewModel.SaveState()); pageState[Constants.DocumentDetailPageState] = serializedState; // OnNavigatedFrom would be called *before* SaveState (unless we call base. first), that's why we destroy the references here DataContext = null; ViewModel = null; // Click event handler for the AppBar have to be manually deregistered, otherwise the Page object will stick around RefreshAppBarButton.Click -= AppBarButton_WithDismissBehavior_OnClick; ViewAttachments.Click -= ViewAttachments_OnClick; SaveHtmlAppBarButton.Click -= AppBarButton_WithDismissBehavior_OnClick; }