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 : IUIViewSettingspublic sealed class UIViewSettings : IUIViewSettingsPublic NotInheritable Class UIViewSettings Implements IUIViewSettings// You can use this class in JavaScript.
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

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

public : UserInteractionMode UserInteractionMode { get; }public UserInteractionMode UserInteractionMode { get; }Public ReadOnly Property UserInteractionMode As UserInteractionMode// You can use this property in JavaScript.
Value
UserInteractionMode UserInteractionMode UserInteractionMode UserInteractionMode

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.

Some devices (PC, laptop, tablet) support both a Desktop (mouse-optimized) and a Tablet (touch-optimized) 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.

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.

Methods

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.

public : static UIViewSettings GetForCurrentView()public static UIViewSettings GetForCurrentView()Public Static Function GetForCurrentView() As UIViewSettings// You can use this method in JavaScript.
Returns

A UIViewSettings instance that can be used to get and set view settings properties.

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