我的工作是Windows 10和Windows 10 Mobile的通用应用程序。有人知道如何检查Windows 10是否在平板电脑模式下运行吗?
我在这里发现了这个问题,但这是针对Windows Forms的:How can I detect when Window 10 enters tablet mode in a Windows Forms application?
谢谢
发布于 2015-10-09 23:07:14
You 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;
}发布于 2020-11-20 01:15:44
我认为下面的代码可以帮助你:
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;
}https://stackoverflow.com/questions/33041370
复制相似问题