当前位置: 代码迷 >> C# >> c#下如何判断判断系统是桌面模式还是平板模式
  详细解决方案

c#下如何判断判断系统是桌面模式还是平板模式

热度:27   发布时间:2016-05-05 02:37:43.0
c#下怎么判断判断系统是桌面模式还是平板模式?
c#下怎么监听判断系统是桌面模式还是平板模式?比如:通过什么事件监听到当前surface pro是desktop模式还是平板模式?
------解决思路----------------------

using Windows.UI.Xaml;
using Windows.UI.ViewManagement;
 
    public sealed partial class MainPage : Page
    {
        public MainPage()
        {
            InitializeComponent();
            // Every view gets an initial SizeChanged, so we will do all our 
            // work there. This means that our view also responds to dynamic
            // changes in user interaction mode.
            Window.Current.SizeChanged += SizeChanged;
        }
 
        private void SizeChanged(object sender, RoutedEventArgs e)
        {
            switch(UIViewSettings.GetForCurrentView().UserInteractionMode)
            {
                case UserInteractionMode.Mouse:
                    VisualStateManager.GoToState(this, "MouseLayout", true);
                    break;
 
                case UserInteractionMode.Touch:
                default:
                    VisualStateManager.GoToState(this, "TouchLayout", true);
                    break;
            }
        }
     }

msdn上找到的一段代码,希望有用
  相关解决方案