了解Windows 10何时是平板电脑模式 - Windows 10 / Windows 10 Mobile

时间:2015-10-09 14:54:46

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

我在适用于Windows 10和Windows 10 Mobile的Universal App上工作。 有谁知道如何检查Windows 10是否在平板电脑模式下运行?

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

由于

2 个答案:

答案 0 :(得分:5)

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;
}

答案 1 :(得分:0)

我认为下面的这段代码可以为您提供帮助:

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;
}