UIViewSettings UIViewSettings UIViewSettings UIViewSettings UIViewSettings Class

Definition

Represents UI states and behaviors associated with the device mode (Tablet or Desktop) and input device type.

public : sealed class UIViewSettings
struct winrt::Windows::UI::ViewManagement::UIViewSettings
public sealed class UIViewSettings
Public NotInheritable Class UIViewSettings
// This class does not provide a public constructor.
Attributes

Windows 10 requirements

Device family
Windows 10 (introduced v10.0.10240.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v1)

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

To get an instance of this class, call GetForCurrentView.

Note

Some devices (PC, laptop, tablet) support both Desktop and Tablet mode.

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.

Properties

UserInteractionMode UserInteractionMode UserInteractionMode UserInteractionMode UserInteractionMode

Gets a value that indicates whether the device UI is optimized for touch input or mouse input.

Methods

GetForCurrentView() GetForCurrentView() GetForCurrentView() GetForCurrentView() GetForCurrentView()

Gets the UI states and behaviors associated with the device mode (Tablet or Desktop) for the active app.

Note

Some devices (PC, laptop, tablet) support both Desktop and Tablet mode.

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.