UIViewSettings.UserInteractionMode Property
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Gets a value that indicates whether the device UI is optimized for touch input or mouse input.
public:
property UserInteractionMode UserInteractionMode { UserInteractionMode get(); };
UserInteractionMode UserInteractionMode();
public UserInteractionMode UserInteractionMode { get; }
var userInteractionMode = uIViewSettings.userInteractionMode;
Public ReadOnly Property UserInteractionMode As UserInteractionMode
Property Value
A value that indicates the input type (mouse or touch) the device UI is optimized for.
Examples
Here, we show how to use the interaction mode to optimize the app layout on launch or when the device mode is changed.
using Windows.UI.Xaml;
using Windows.UI.ViewManagement;
public sealed partial class MainPage : Page
{
public MainPage()
{
InitializeComponent();
// Every view gets an initial SizeChanged, so we will do all our
// work there. This means that our view also responds to dynamic
// changes in user interaction mode.
Window.Current.SizeChanged += SizeChanged;
}
private void SizeChanged(object sender, RoutedEventArgs e)
{
switch(UIViewSettings.GetForCurrentView().UserInteractionMode)
{
case UserInteractionMode.Mouse:
VisualStateManager.GoToState(this, "MouseLayout", true);
break;
case UserInteractionMode.Touch:
default:
VisualStateManager.GoToState(this, "TouchLayout", true);
break;
}
}
}
Remarks
This property can be used to optimize your app based on input type.
Tablet mode
Important
Windows 11 and newer
Tablet Mode is not supported.
Pending new functionality, please use Convertible Slate Mode (CSM) to detect the keyboard attach and detach events.
Some devices (PC, laptop, tablet) support both a Desktop (mouse-optimized) and a Tablet (touch-optimized) mode.
On Windows 10 only, users can switch between running in Tablet mode and Desktop mode by going to Settings > System > Tablet mode and setting Make Windows more touch-friendly when using your device as a tablet.
In Tablet mode, app views are auto-maximized and the title bar is hidden. The taskbar remains visible. The system raises the CoreWindow.SizeChanged event when the value of this property changes. This is exposed to XAML apps as the Window.SizeChanged event and to HTML apps as the window.resize event.