我正在为Windows 10和Windows 10 Mobile开发通用应用程序。
有人知道如何检查Windows 10是否在平板模式下运行吗?
我在这里找到了一个相关问题,但那是针对Windows Forms的:如何在Windows Forms应用程序中检测Window 10进入平板模式? 谢谢。
我在这里找到了一个相关问题,但那是针对Windows Forms的:如何在Windows Forms应用程序中检测Window 10进入平板模式? 谢谢。
您可以查询UserInteractionMode - 这是来自该链接的示例代码
switch(UIViewSettings.GetForCurrentView().UserInteractionMode)
{
case UserInteractionMode.Mouse:
VisualStateManager.GoToState(this, "MouseLayout", true);
break;
case UserInteractionMode.Touch:
default:
VisualStateManager.GoToState(this, "TouchLayout", true);
break;
}
我认为下面的代码可以帮助你:
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;
}