我在适用于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?
由于
答案 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;
}