private void ItemGridViewOnLoaded(object sender, RoutedEventArgs routedEventArgs) { if (_horizontalOffset != null) { ScrollViewerHelpers.ScrollToHorizontalOffset(itemGridView, _horizontalOffset.Value); } }
protected override void SaveState(Dictionary <String, Object> pageState) { DataTransferManager.GetForCurrentView().DataRequested -= OnDataRequested; var state = ViewModel.SaveState(); double offset = ScrollViewerHelpers.GetHorizontalOffset(itemGridView); state.GridViewHorizontalOffset = offset; string serializedState = SerializationHelper.SerializeToString(state); pageState[Constants.SearchResultsPageState] = serializedState; }
// NOT IN USE BECAUSE: when returning from a search, a new item is added at the top, thus making the previous scroll position invalid private void ScrollListViewsToSavedPosition() { // If the controls weren't loaded, accessing them will cause crashes if (!_pastOnLoaded) { return; } if (null != _historyVerticalOffset && ViewModel.SearchHistory != null) { ScrollViewerHelpers.ScrollToVerticalOffset(searchHistoryListView, _historyVerticalOffset.Value); } if (null != _downloadsVerticalOffset && ViewModel.DownloadedDocuments != null) { ScrollViewerHelpers.ScrollToVerticalOffset(downloadsListView, _downloadsVerticalOffset.Value); } }
protected override void SaveState(Dictionary <String, Object> pageState) { MessengerHelper.Unregister(this, MessengerHelper.SearchHistoryDeleted); MessengerHelper.Unregister(this, MessengerHelper.DownloadsDeleted); MessengerHelper.Unregister(this, MessengerHelper.DbLoadCompleted); var state = ViewModel.SaveState(); state.SearchHistoryVerticalOffset = ScrollViewerHelpers.GetVerticalOffset(searchHistoryListView); state.DownloadsVerticalOffset = ScrollViewerHelpers.GetVerticalOffset(downloadsListView); string serializedState = SerializationHelper.SerializeToString(state); pageState[Constants.MainPageState] = serializedState; // OnNavigatedFrom would be called *before* SaveState (unless we call base. first), that's why we destroy the references here DataContext = null; ViewModel = null; }