【问题标题】:Know when Windows 10 are Tablet Mode - Windows 10 / Windows 10 Mobile了解 Windows 10 何时为平板电脑模式 - Windows 10 / Windows 10 Mobile
【发布时间】:2016-01-07 14:03:15
【问题描述】:

我从事适用于 Windows 10 和 Windows 10 移动版的通用应用程序。 有谁知道如何检查 Windows 10 是否在平板电脑模式下运行?

我在这里找到了这个问题,但这是针对 Windows 窗体的:How can I detect when Window 10 enters tablet mode in a Windows Forms application?

谢谢

【问题讨论】:

    标签: c# windows-10 windows-10-mobile


    【解决方案1】:

    我认为下面的代码可以帮助你:

    UIViewSettings^ uiViewSettings = UIViewSettings::GetForCurrentView();
    UserInteractionMode mode = uiViewSettings->UserInteractionMode;
    switch (mode)
    {
    case UserInteractionMode::Touch:
      // PC is in tablet mode or other touch-first environment
      break;
    
    case UserInteractionMode::Mouse:
      // PC is not in tablet mode or other mouse-first environment
      break;
    }
    

    【讨论】:

      【解决方案2】:

      query the UserInteractionMode - 这是来自该链接的示例代码

      switch(UIViewSettings.GetForCurrentView().UserInteractionMode)
      {
        case UserInteractionMode.Mouse:
          VisualStateManager.GoToState(this, "MouseLayout", true);
          break;
      
        case UserInteractionMode.Touch:
        default:
          VisualStateManager.GoToState(this, "TouchLayout", true);
          break;
      }
      

      【讨论】:

      • case UserInteractionMode.Touch:默认:应该是触摸模式。 :)
      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2015-11-16
      • 1970-01-01
      • 2016-03-25
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多