How to prevent/disable snapped view for Windows 8 Metro UI applications

萝らか妹 提交于 2019-12-21 06:29:44

问题


I have an application that really makes no sense for snapped view, as the content generally represents A4 pages of information and data collection.

Is there a way to disable snapped view for the application, or is the recommended approach to just show the application icon, while in snapped mode?


回答1:


You cannot disable snapped view.

Simply just create a new page and navigate to that page if a snap event occurred. You can simply display an image.

Window.Current.SizeChanged += (object sender, Windows.UI.Core.WindowSizeChangedEventArgs e) =>
                {
                    ApplicationViewState myViewState = ApplicationView.Value;

                    if (myViewState == ApplicationViewState.Snapped)
                    {
                        //await SaveAssets();
                        this.Frame.Navigate(typeof(Snapped));
                        Snapped = true;
                    }
                    else if (myViewState != ApplicationViewState.Snapped)
                    {
                        if (Snapped)
                        {
                            this.Frame.Navigate(typeof(MainPage));
                            Snapped = false;
                        }
                    }
                };



回答2:


I really like Robert's solution. Based upon that, you can simulate disabling snapped view:

Window.Current.SizeChanged += async (object sender, WindowSizeChangedEventArgs e) =>
        {
            ApplicationViewState myViewState = ApplicationView.Value;
            if (myViewState == ApplicationViewState.Snapped)
            {
                if (!ApplicationView.TryUnsnap())
                {
                    MessageDialog dialog = new MessageDialog("Sorry, this App is unusable in snapped mode.");
                    await dialog.ShowAsync();
                }
            }
        };  


来源:https://stackoverflow.com/questions/12240421/how-to-prevent-disable-snapped-view-for-windows-8-metro-ui-applications

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!