fipcurren88
fipcurren88

Reputation: 701

Know when Windows 10 are Tablet Mode - Windows 10 / Windows 10 Mobile

I work on Universal App for Windows 10 and Windows 10 Mobile. Does anyone know how to check if Windows 10 is running on Tablet Mode?

I found this question here but that is for Windows Forms: How can I detect when Window 10 enters tablet mode in a Windows Forms application?

Thanks

Upvotes: 3

Views: 1453

Answers (2)

farshid aminzadeh
farshid aminzadeh

Reputation: 1

I think this code below can help you:

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

Upvotes: 0

stuartd
stuartd

Reputation: 73253

You query the UserInteractionMode - this is the sample code from that link

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

  case UserInteractionMode.Touch:
  default:
    VisualStateManager.GoToState(this, "TouchLayout", true);
    break;
}

Upvotes: 5

Related Questions