private async Task UpdateSelectedAsync(HamburgerButtonInfo previous, HamburgerButtonInfo value) { DebugWrite($"OldValue: {previous}, NewValue: {value}"); // pls. do not remove this if statement. this is the fix for #410 (click twice) if (previous != null) { IsOpen = (DisplayMode == SplitViewDisplayMode.CompactInline && IsOpen); } // signal previous if (previous != null && previous != value && previous.IsChecked.Value) { previous.IsChecked = false; previous.RaiseUnselected(); // Workaround for visual state of ToggleButton not reset correctly if (value != null) { var control = LoadedNavButtons.First(x => x.HamburgerButtonInfo == value).GetElement <Control>(); VisualStateManager.GoToState(control, "Normal", true); } } // navigate only when all navigation buttons have been loaded if (AllNavButtonsAreLoaded && value?.PageType != null) { if (await NavigationService.NavigateAsync(value.PageType, value?.PageParameter, value?.NavigationTransitionInfo)) { IsOpen = (DisplayMode == SplitViewDisplayMode.CompactInline && IsOpen); if (value.ClearHistory) { NavigationService.ClearHistory(); } if (value.ClearCache) { NavigationService.ClearCache(true); } } else if (NavigationService.CurrentPageType == value.PageType && (NavigationService.CurrentPageParam ?? string.Empty) == (value.PageParameter ?? string.Empty)) { if (value.ClearHistory) { NavigationService.ClearHistory(); } if (value.ClearCache) { NavigationService.ClearCache(true); } } else if (NavigationService.CurrentPageType == value.PageType) { // just check it } else { return; } } // that's it if null if (value == null) { return; } else { value.IsChecked = (value.ButtonType == HamburgerButtonInfo.ButtonTypes.Toggle); if (previous != value) { value.RaiseSelected(); } } }
private async Task UpdateSelectedAsync(HamburgerButtonInfo previous, HamburgerButtonInfo current) { // pls. do not remove this if statement. this is the fix for #410 (click twice) if (previous != null) { IsOpen = (DisplayMode == SplitViewDisplayMode.CompactInline && IsOpen); } // signal previous if (previous != null && previous != current && previous.IsChecked.Value) { // Workaround for visual state of ToggleButton not reset correctly if (current != null) { var control = LoadedNavButtons.First(x => x.HamburgerButtonInfo == current).GetElement <Control>(); VisualStateManager.GoToState(control, "Normal", true); } } // navigate only when all navigation buttons have been loaded if (AllNavButtonsAreLoaded && current?.PageType != null) { if (await NavigationService.NavigateAsync(current.PageType, current?.PageParameter, current?.NavigationTransitionInfo)) { SignalPreviousPage(previous, current); SignalCurrentPage(previous, current); IsOpen = (DisplayMode == SplitViewDisplayMode.CompactInline && IsOpen); if (current.ClearHistory) { NavigationService.ClearHistory(); } if (current.ClearCache) { var frameState = await(NavigationService.FrameFacade as ITemplate10FrameInternal).GetFrameStateAsync(); await frameState.ClearAsync(); } } else if (NavigationService.CurrentPageType == current.PageType && (NavigationService.CurrentPageParam ?? string.Empty) == (current.PageParameter ?? string.Empty)) { SignalPreviousPage(previous, current); SignalCurrentPage(previous, current); if (current.ClearHistory) { NavigationService.ClearHistory(); } if (current.ClearCache) { var frameState = await(NavigationService.FrameFacade as ITemplate10FrameInternal).GetFrameStateAsync(); await frameState.ClearAsync(); } } else if (previous == null || NavigationService.CurrentPageType == current.PageType) { SignalCurrentPage(previous, current); } else { // Re-instate Selected to previous page, but avoid calling this method (UpdateSelectedAsync) all over // again, and we use a flag to effect this. See InternalSelectedChanged() method where it's used. _isUpdateSelectedRunning = true; try { Selected = previous; } finally { _isUpdateSelectedRunning = false; } current.IsChecked = false; current.RaiseUnselected(); return; } } else { SignalPreviousPage(previous, current); SignalCurrentPage(previous, current); } }