public override void CreatedWindow_SetWindowRectangle(RectangleI rectangle) { //TODO: implement it. var scaleFactor = displayInfo.RawPixelsPerViewPixel; applicationView.TryResizeView(new Size( (rectangle.Right - rectangle.Left) / scaleFactor, (rectangle.Bottom - rectangle.Top) / scaleFactor)); //!!!!!так? EngineApp._CreatedWindow_ProcessResize(); }
public async Task<bool> TryCreateNewWindowAsync(TabViewViewModel tabView, Size size) { CoreApplicationView newView = CoreApplication.CreateNewView(); int newViewId = 0; await newView.Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () => { ApplicationView applicationView = ApplicationView.GetForCurrentView(); applicationView.SetPreferredMinSize(new Size(MinWindowWidth, MinWindowHeight)); applicationView.TryResizeView(size); Frame frame = new Frame(); frame.Navigate(typeof(AppWindowPage), new TabViewNavigationParameters(tabView)); Window.Current.Content = frame; Window.Current.Activate(); newViewId = ApplicationView.GetForCurrentView().Id; }); bool success = await ApplicationViewSwitcher.TryShowAsStandaloneAsync(newViewId); return success; }
private void BtnClick(object sender, RoutedEventArgs e) { var s = (string)((Button)sender).Tag; var a = s.Split(','); var dx = int.Parse(a[0]); var dy = int.Parse(a[1]); if (dx == 0 && dy == 0) { if (AV.IsFullScreen) { AV.ExitFullScreenMode(); } else { AV.TryEnterFullScreenMode(); } } else { x += dx; y += dy; AV.TryResizeView(new Size(x, y)); } }
private void Grid_Loaded(object sender, RoutedEventArgs e) { ApplicationView view = ApplicationView.GetForCurrentView(); view.TryResizeView(new Size { Width = 920, Height = 700 }); }
public static async Task OpenPropertiesWindowAsync(object item, IShellPage associatedInstance) { if (item == null) { return; } if (ApiInformation.IsApiContractPresent("Windows.Foundation.UniversalApiContract", 8)) { CoreApplicationView newWindow = CoreApplication.CreateNewView(); ApplicationView newView = null; await newWindow.Dispatcher.RunAsync(CoreDispatcherPriority.Normal, async() => { Frame frame = new Frame(); frame.Navigate(typeof(Properties), new PropertiesPageNavigationArguments() { Item = item, AppInstanceArgument = associatedInstance }, new SuppressNavigationTransitionInfo()); Window.Current.Content = frame; Window.Current.Activate(); newView = ApplicationView.GetForCurrentView(); newWindow.TitleBar.ExtendViewIntoTitleBar = true; newView.Title = "PropertiesTitle".GetLocalized(); newView.PersistedStateId = "Properties"; newView.SetPreferredMinSize(new Size(400, 500)); newView.Consolidated += delegate { Window.Current.Close(); }; bool viewShown = await ApplicationViewSwitcher.TryShowAsStandaloneAsync(newView.Id); if (viewShown && newView != null) { // Set window size again here as sometimes it's not resized in the page Loaded event newView.TryResizeView(new Size(400, 550)); } }); } else { var propertiesDialog = new PropertiesDialog(); propertiesDialog.propertiesFrame.Tag = propertiesDialog; propertiesDialog.propertiesFrame.Navigate(typeof(Properties), new PropertiesPageNavigationArguments() { Item = item, AppInstanceArgument = associatedInstance }, new SuppressNavigationTransitionInfo()); await propertiesDialog.ShowAsync(ContentDialogPlacement.Popup); } }
public bool TrySetWindowSize(double width, double height) { ApplicationView applicationView = ApplicationView.GetForCurrentView(); if (previousSize == null) { previousSize = new Size(applicationView.VisibleBounds.Width, applicationView.VisibleBounds.Height); } var preferredSize = new Size(width, height); if (!applicationView.IsFullScreenMode) { var successfull = applicationView.TryResizeView(preferredSize); if (!successfull) { applicationView.TryResizeView(previousSize.Value); } return(successfull); } return(false); }
private async void OpenAdvancedProperties() { if (SecurityProperties == null) { return; } if (ApiInformation.IsApiContractPresent("Windows.Foundation.UniversalApiContract", 8)) { if (propsView == null) { var newWindow = CoreApplication.CreateNewView(); await newWindow.Dispatcher.RunAsync(CoreDispatcherPriority.Normal, async() => { Frame frame = new Frame(); frame.Navigate(typeof(PropertiesSecurityAdvanced), new PropertiesPageNavigationArguments() { Item = SecurityProperties.Item, AppInstanceArgument = AppInstance }, new SuppressNavigationTransitionInfo()); Window.Current.Content = frame; Window.Current.Activate(); propsView = ApplicationView.GetForCurrentView(); newWindow.TitleBar.ExtendViewIntoTitleBar = true; propsView.Title = string.Format("SecurityAdvancedPermissionsTitle".GetLocalized(), SecurityProperties.Item.ItemName); propsView.PersistedStateId = "PropertiesSecurity"; propsView.SetPreferredMinSize(new Size(400, 500)); propsView.Consolidated += PropsView_Consolidated; bool viewShown = await ApplicationViewSwitcher.TryShowAsStandaloneAsync(propsView.Id); if (viewShown && propsView != null) { // Set window size again here as sometimes it's not resized in the page Loaded event propsView.TryResizeView(new Size(850, 550)); } }); } await ApplicationViewSwitcher.SwitchAsync(propsView.Id); } else { // Unsupported } }
protected internal override void Initialize(GameContext windowContext) { swapChainPanel = (windowContext as GameContextUWPXaml)?.Control; coreWindow = (windowContext as GameContextUWPCoreWindow)?.Control; if (swapChainPanel != null) { resizeTimer = new DispatcherTimer { Interval = TimeSpan.FromMilliseconds(100) }; resizeTimer.Tick += ResizeTimerOnTick; coreWindow = CoreWindow.GetForCurrentThread(); windowHandle = new WindowHandle(AppContextType.UWPXaml, swapChainPanel, IntPtr.Zero); } else if (coreWindow != null) { coreWindow.SizeChanged += ResizeOnWindowChange; windowHandle = new WindowHandle(AppContextType.UWPCoreWindow, coreWindow, IntPtr.Zero); } else { Debug.Assert(swapChainPanel == null && coreWindow == null, "GameContext was neither UWPXaml nor UWPCoreWindow"); } applicationView = ApplicationView.GetForCurrentView(); if (applicationView != null && windowContext.RequestedWidth != 0 && windowContext.RequestedHeight != 0) { applicationView.SetPreferredMinSize(new Size(windowContext.RequestedWidth, windowContext.RequestedHeight)); canResize = applicationView.TryResizeView(new Size(windowContext.RequestedWidth, windowContext.RequestedHeight)); } requiredRatio = windowContext.RequestedWidth / (double)windowContext.RequestedHeight; if (swapChainPanel != null) { swapChainPanel.SizeChanged += swapChainPanel_SizeChanged; swapChainPanel.CompositionScaleChanged += swapChainPanel_CompositionScaleChanged; } coreWindow.SizeChanged += CurrentWindowOnSizeChanged; visible = coreWindow.Visible; coreWindow.VisibilityChanged += CurrentWindowOnVisibilityChanged; coreWindow.Activated += CurrentWindowOnActivated; }
protected override void Initialize(GameContext <SwapChainPanel> windowContext) { Debug.Assert(windowContext is GameContextUWP, "By design only one descendant of GameContext<SwapChainPanel>"); swapChainPanel = windowContext.Control; windowHandle = new WindowHandle(AppContextType.UWP, swapChainPanel, IntPtr.Zero); applicationView = ApplicationView.GetForCurrentView(); if (applicationView != null && windowContext.RequestedWidth != 0 && windowContext.RequestedHeight != 0) { applicationView.SetPreferredMinSize(new Size(windowContext.RequestedWidth, windowContext.RequestedHeight)); canResize = applicationView.TryResizeView(new Size(windowContext.RequestedWidth, windowContext.RequestedHeight)); } requiredRatio = windowContext.RequestedWidth / (double)windowContext.RequestedHeight; swapChainPanel.SizeChanged += swapChainPanel_SizeChanged; swapChainPanel.CompositionScaleChanged += swapChainPanel_CompositionScaleChanged; coreWindow.SizeChanged += CurrentWindowOnSizeChanged; }
private void btnChangeSize_Click(object sender, RoutedEventArgs e) { ApplicationView applicationView = ApplicationView.GetForCurrentView(); Size size = new Size(600, 600); // TryResizeView(Size value) - 尝试将窗口尺寸设置为指定的大小 bool success = applicationView.TryResizeView(size); if (success) { lblMsg.Text = "尝试修改窗口尺寸成功"; } else { lblMsg.Text = "尝试修改窗口尺寸失败"; } // 注:怎么修改窗口的显示位置呢?暂时不知道 }
internal void SetClientSize(int width, int height) { if (_appView.IsFullScreenMode) { return; } if (_viewBounds.Width == width && _viewBounds.Height == height) { return; } var viewSize = new Windows.Foundation.Size(width / _dinfo.RawPixelsPerViewPixel, height / _dinfo.RawPixelsPerViewPixel); //_appView.SetPreferredMinSize(viewSize); if (!_appView.TryResizeView(viewSize)) { // TODO: What now? } }
public GameWindowUwp(Game game) : base(game) { GameContext gameContext = game.Context; switch (gameContext) { case GameContextCoreWindow coreWindowContext: coreWindow = coreWindowContext.Control; windowHandle = new WindowHandle(AppContextType.CoreWindow, coreWindow, IntPtr.Zero); break; case GameContextXaml xamlContext: coreWindow = CoreWindow.GetForCurrentThread(); swapChainPanel = xamlContext.Control; windowHandle = new WindowHandle(AppContextType.Xaml, swapChainPanel, IntPtr.Zero); swapChainPanel.SizeChanged += SwapChainPanel_SizeChanged; swapChainPanel.CompositionScaleChanged += SwapChainPanel_CompositionScaleChanged; break; default: throw new ArgumentException(); } coreWindow.SizeChanged += CoreWindow_SizeChanged; applicationView = ApplicationView.GetForCurrentView(); if (gameContext.RequestedWidth != 0 && gameContext.RequestedHeight != 0) { applicationView.SetPreferredMinSize(new Windows.Foundation.Size(gameContext.RequestedWidth, gameContext.RequestedHeight)); applicationView.TryResizeView(new Windows.Foundation.Size(gameContext.RequestedWidth, gameContext.RequestedHeight)); } }
private async Task <PlayerViewManager> GetEnsureSecondaryView() { if (IsMainView && SecondaryCoreAppView == null) { var playerView = CoreApplication.CreateNewView(); HohoemaSecondaryViewFrameViewModel vm = null; int id = 0; ApplicationView view = null; INavigationService ns = null; await playerView.Dispatcher.RunAsync(CoreDispatcherPriority.Normal, async() => { // SecondaryViewのスケジューラをセットアップ SecondaryViewScheduler = new CoreDispatcherScheduler(playerView.Dispatcher); playerView.TitleBar.ExtendViewIntoTitleBar = true; var content = new Views.HohoemaSecondaryViewFrame(); var frameFacade = new FrameFacadeAdapter(content.Frame, EventAggregator); var sessionStateService = new SessionStateService(); //sessionStateService.RegisterFrame(frameFacade, "secondary_view_player"); ns = new FrameNavigationService(frameFacade , (pageToken) => { if (pageToken == nameof(Views.VideoPlayerPage)) { return(typeof(Views.VideoPlayerPage)); } else if (pageToken == nameof(Views.LivePlayerPage)) { return(typeof(Views.LivePlayerPage)); } else { return(typeof(Views.BlankPage)); } }, sessionStateService); vm = content.DataContext as HohoemaSecondaryViewFrameViewModel; Window.Current.Content = content; id = ApplicationView.GetApplicationViewIdForWindow(playerView.CoreWindow); view = ApplicationView.GetForCurrentView(); view.TitleBar.ButtonBackgroundColor = Windows.UI.Colors.Transparent; view.TitleBar.ButtonInactiveBackgroundColor = Windows.UI.Colors.Transparent; Window.Current.Activate(); await ApplicationViewSwitcher.TryShowAsStandaloneAsync(id, ViewSizePreference.UseHalf, MainViewId, ViewSizePreference.UseHalf); // ウィンドウサイズの保存と復元 if (Services.Helpers.DeviceTypeHelper.IsDesktop) { var localObjectStorageHelper = App.Current.Container.Resolve <Microsoft.Toolkit.Uwp.Helpers.LocalObjectStorageHelper>(); if (localObjectStorageHelper.KeyExists(secondary_view_size)) { view.TryResizeView(localObjectStorageHelper.Read <Size>(secondary_view_size)); } view.VisibleBoundsChanged += View_VisibleBoundsChanged; } view.Consolidated += SecondaryAppView_Consolidated; }); SecondaryAppView = view; _SecondaryViewVM = vm; SecondaryCoreAppView = playerView; SecondaryViewPlayerNavigationService = ns; App.Current.Container.RegisterInstance(SECONDARY_VIEW_PLAYER_NAVIGATION_SERVICE, SecondaryViewPlayerNavigationService); } return(this); }
public MainPage() { this.InitializeComponent(); AV = ApplicationView.GetForCurrentView(); AV.TryResizeView(new Size(x, y)); }
private async Task <HohoemaViewManager> GetEnsureSecondaryView() { if (CoreAppView == null) { var playerView = CoreApplication.CreateNewView(); HohoemaSecondaryViewFrameViewModel vm = null; int id = 0; ApplicationView view = null; INavigationService ns = null; await playerView.Dispatcher.RunAsync(CoreDispatcherPriority.Normal, async() => { playerView.TitleBar.ExtendViewIntoTitleBar = true; var content = new Views.HohoemaSecondaryViewFrame(); var frameFacade = new FrameFacadeAdapter(content.Frame); var sessionStateService = new SessionStateService(); ns = new FrameNavigationService(frameFacade , (pageToken) => { if (pageToken == nameof(Views.VideoPlayerPage)) { return(typeof(Views.VideoPlayerPage)); } else if (pageToken == nameof(Views.LivePlayerPage)) { return(typeof(Views.LivePlayerPage)); } else { return(typeof(Views.BlankPage)); } }, sessionStateService); vm = content.DataContext as HohoemaSecondaryViewFrameViewModel; Window.Current.Content = content; id = ApplicationView.GetApplicationViewIdForWindow(playerView.CoreWindow); view = ApplicationView.GetForCurrentView(); view.TitleBar.ButtonBackgroundColor = Windows.UI.Colors.Transparent; view.TitleBar.ButtonInactiveBackgroundColor = Windows.UI.Colors.Transparent; Window.Current.Activate(); await ApplicationViewSwitcher.TryShowAsStandaloneAsync(id, ViewSizePreference.Default, MainView.Id, ViewSizePreference.Default); // ウィンドウサイズの保存と復元 if (Helpers.DeviceTypeHelper.IsDesktop) { var localObjectStorageHelper = App.Current.Container.Resolve <Microsoft.Toolkit.Uwp.Helpers.LocalObjectStorageHelper>(); if (localObjectStorageHelper.KeyExists(secondary_view_size)) { view.TryResizeView(localObjectStorageHelper.Read <Size>(secondary_view_size)); } view.VisibleBoundsChanged += View_VisibleBoundsChanged; } view.Consolidated += SecondaryAppView_Consolidated; }); ViewId = id; AppView = view; _SecondaryViewVM = vm; CoreAppView = playerView; NavigationService = ns; } NowShowingSecondaryView = true; return(this); }
public static async Task OpenPropertiesWindowAsync(object item, IShellPage associatedInstance) { if (item == null) { return; } if (ApiInformation.IsApiContractPresent("Windows.Foundation.UniversalApiContract", 8)) { if (WindowDecorationsHelper.IsWindowDecorationsAllowed) { AppWindow appWindow = await AppWindow.TryCreateAsync(); Frame frame = new Frame(); frame.RequestedTheme = ThemeHelper.RootTheme; frame.Navigate(typeof(Properties), new PropertiesPageNavigationArguments() { Item = item, AppInstanceArgument = associatedInstance }, new SuppressNavigationTransitionInfo()); ElementCompositionPreview.SetAppWindowContent(appWindow, frame); (frame.Content as Properties).appWindow = appWindow; appWindow.TitleBar.ExtendsContentIntoTitleBar = true; appWindow.Title = "PropertiesTitle".GetLocalized(); appWindow.PersistedStateId = "Properties"; WindowManagementPreview.SetPreferredMinSize(appWindow, new Size(460, 550)); bool windowShown = await appWindow.TryShowAsync(); if (windowShown) { // Set window size again here as sometimes it's not resized in the page Loaded event appWindow.RequestSize(new Size(460, 550)); DisplayRegion displayRegion = ApplicationView.GetForCurrentView().GetDisplayRegions()[0]; Point pointerPosition = CoreWindow.GetForCurrentThread().PointerPosition; appWindow.RequestMoveRelativeToDisplayRegion(displayRegion, new Point(pointerPosition.X - displayRegion.WorkAreaOffset.X, pointerPosition.Y - displayRegion.WorkAreaOffset.Y)); } } else { CoreApplicationView newWindow = CoreApplication.CreateNewView(); ApplicationView newView = null; await newWindow.Dispatcher.RunAsync(CoreDispatcherPriority.Normal, async() => { Frame frame = new Frame(); frame.RequestedTheme = ThemeHelper.RootTheme; frame.Navigate(typeof(Properties), new PropertiesPageNavigationArguments() { Item = item, AppInstanceArgument = associatedInstance }, new SuppressNavigationTransitionInfo()); Window.Current.Content = frame; Window.Current.Activate(); newView = ApplicationView.GetForCurrentView(); newWindow.TitleBar.ExtendViewIntoTitleBar = true; newView.Title = "PropertiesTitle".GetLocalized(); newView.PersistedStateId = "Properties"; newView.SetPreferredMinSize(new Size(460, 550)); bool viewShown = await ApplicationViewSwitcher.TryShowAsStandaloneAsync(newView.Id); if (viewShown && newView != null) { // Set window size again here as sometimes it's not resized in the page Loaded event newView.TryResizeView(new Size(460, 550)); } }); } } else { var propertiesDialog = new PropertiesDialog(); propertiesDialog.propertiesFrame.Tag = propertiesDialog; propertiesDialog.propertiesFrame.Navigate(typeof(Properties), new PropertiesPageNavigationArguments() { Item = item, AppInstanceArgument = associatedInstance }, new SuppressNavigationTransitionInfo()); await propertiesDialog.ShowAsync(ContentDialogPlacement.Popup); } }
private void OnAppLaunch(IActivatedEventArgs args, string argument) { // Uncomment the following lines to display frame-rate and per-frame CPU usage info. //#if _DEBUG // if (IsDebuggerPresent()) // { // DebugSettings->EnableFrameRateCounter = true; // } //#endif args.SplashScreen.Dismissed += DismissedEventHandler; var rootFrame = (Window.Current.Content as Frame); WeakReference weak = new WeakReference(this); float minWindowWidth = (float)((double)Resources[ApplicationResourceKeys.Globals.AppMinWindowWidth]); float minWindowHeight = (float)((double)Resources[ApplicationResourceKeys.Globals.AppMinWindowHeight]); Size minWindowSize = SizeHelper.FromDimensions(minWindowWidth, minWindowHeight); ApplicationView appView = ApplicationView.GetForCurrentView(); ApplicationDataContainer localSettings = ApplicationData.Current.LocalSettings; // For very first launch, set the size of the calc as size of the default standard mode if (!localSettings.Values.ContainsKey("VeryFirstLaunch")) { localSettings.Values["VeryFirstLaunch"] = false; appView.SetPreferredMinSize(minWindowSize); appView.TryResizeView(minWindowSize); } else { ApplicationView.PreferredLaunchWindowingMode = ApplicationViewWindowingMode.Auto; } // Do not repeat app initialization when the Window already has content, // just ensure that the window is active if (rootFrame == null) { if (!Windows.Foundation.Metadata.ApiInformation.IsTypePresent("Windows.Phone.UI.Input.HardwareButtons")) // PC Family { // Disable the system view activation policy during the first launch of the app // only for PC family devices and not for phone family devices try { ApplicationViewSwitcher.DisableSystemViewActivationPolicy(); } catch (Exception) { // Log that DisableSystemViewActionPolicy didn't work } } // Create a Frame to act as the navigation context rootFrame = App.CreateFrame(); // When the navigation stack isn't restored navigate to the first page, // configuring the new page by passing required information as a navigation // parameter if (!rootFrame.Navigate(typeof(MainPage), argument)) { // We couldn't navigate to the main page, kill the app so we have a good // stack to debug throw new SystemException(); } SetMinWindowSizeAndThemeAndActivate(rootFrame, minWindowSize); m_mainViewId = ApplicationView.GetForCurrentView().Id; AddWindowToMap(WindowFrameService.CreateNewWindowFrameService(rootFrame, false, weak)); } else { // For first launch, LaunchStart is logged in constructor, this is for subsequent launches. // !Phone check is required because even in continuum mode user interaction mode is Mouse not Touch if ((UIViewSettings.GetForCurrentView().UserInteractionMode == UserInteractionMode.Mouse) && (!Windows.Foundation.Metadata.ApiInformation.IsTypePresent("Windows.Phone.UI.Input.HardwareButtons"))) { // If the pre-launch hasn't happened then allow for the new window/view creation if (!m_preLaunched) { var newCoreAppView = CoreApplication.CreateNewView(); _ = newCoreAppView.Dispatcher.RunAsync( CoreDispatcherPriority.Normal, async() => { var that = weak.Target as App; if (that != null) { var newRootFrame = App.CreateFrame(); SetMinWindowSizeAndThemeAndActivate(newRootFrame, minWindowSize); if (!newRootFrame.Navigate(typeof(MainPage), argument)) { // We couldn't navigate to the main page, kill the app so we have a good // stack to debug throw new SystemException(); } var frameService = WindowFrameService.CreateNewWindowFrameService(newRootFrame, true, weak); that.AddWindowToMap(frameService); var dispatcher = CoreWindow.GetForCurrentThread().Dispatcher; // CSHARP_MIGRATION_ANNOTATION: // class SafeFrameWindowCreation is being interpreted into a IDisposable class // in order to enhance its RAII capability that was written in C++/CX using (var safeFrameServiceCreation = new SafeFrameWindowCreation(frameService, that)) { int newWindowId = ApplicationView.GetApplicationViewIdForWindow(CoreWindow.GetForCurrentThread()); ActivationViewSwitcher activationViewSwitcher = null; var activateEventArgs = (args as IViewSwitcherProvider); if (activateEventArgs != null) { activationViewSwitcher = activateEventArgs.ViewSwitcher; } if (activationViewSwitcher != null) { _ = activationViewSwitcher.ShowAsStandaloneAsync(newWindowId, ViewSizePreference.Default); safeFrameServiceCreation.SetOperationSuccess(true); } else { var activatedEventArgs = (args as IApplicationViewActivatedEventArgs); if ((activatedEventArgs != null) && (activatedEventArgs.CurrentlyShownApplicationViewId != 0)) { // CSHARP_MIGRATION_ANNOTATION: // here we don't use ContinueWith() to interpret origin code because we would like to // pursue the design of class SafeFrameWindowCreate whichi was using RAII to ensure // some states get handled properly when its instance is being destructed. // // To achieve that, SafeFrameWindowCreate has been reinterpreted using IDisposable // pattern, which forces we use below way to keep async works being controlled within // a same code block. var viewShown = await ApplicationViewSwitcher.TryShowAsStandaloneAsync( frameService.GetViewId(), ViewSizePreference.Default, activatedEventArgs.CurrentlyShownApplicationViewId, ViewSizePreference.Default); // SafeFrameServiceCreation is used to automatically remove the frame // from the list of frames if something goes bad. safeFrameServiceCreation.SetOperationSuccess(viewShown); } } } } }); } else { ActivationViewSwitcher activationViewSwitcher = null; var activateEventArgs = (args as IViewSwitcherProvider); if (activateEventArgs != null) { activationViewSwitcher = activateEventArgs.ViewSwitcher; } if (activationViewSwitcher != null) { _ = activationViewSwitcher.ShowAsStandaloneAsync( ApplicationView.GetApplicationViewIdForWindow(CoreWindow.GetForCurrentThread()), ViewSizePreference.Default); } else { TraceLogger.GetInstance().LogError(ViewMode.None, "App.OnAppLaunch", "Null_ActivationViewSwitcher"); } } // Set the preLaunched flag to false m_preLaunched = false; } else // for touch devices { if (rootFrame.Content == null) { // When the navigation stack isn't restored navigate to the first page, // configuring the new page by passing required information as a navigation // parameter if (!rootFrame.Navigate(typeof(MainPage), argument)) { // We couldn't navigate to the main page, // kill the app so we have a good stack to debug throw new SystemException(); } } if (ApplicationView.GetForCurrentView().ViewMode != ApplicationViewMode.CompactOverlay) { if (!Windows.Foundation.Metadata.ApiInformation.IsTypePresent("Windows.Phone.UI.Input.HardwareButtons")) { // for tablet mode: since system view activation policy is disabled so do ShowAsStandaloneAsync if activationViewSwitcher exists in // activationArgs ActivationViewSwitcher activationViewSwitcher = null; var activateEventArgs = (args as IViewSwitcherProvider); if (activateEventArgs != null) { activationViewSwitcher = activateEventArgs.ViewSwitcher; } if (activationViewSwitcher != null) { var viewId = (args as IApplicationViewActivatedEventArgs).CurrentlyShownApplicationViewId; if (viewId != 0) { _ = activationViewSwitcher.ShowAsStandaloneAsync(viewId); } } } // Ensure the current window is active Window.Current.Activate(); } } } }