UIViewSettings.GetForCurrentView メソッド

定義

アクティブなアプリのデバイス モード (タブレットまたはデスクトップ) に関連付けられている UI の状態と動作を取得します。

タブレット モード (Windows 10のみ)

注意

Windows 11では、タブレット モードが削除され、キーボードのアタッチとデタッチの姿勢に新しい機能が含まれています。

一部のデバイス (PC、ノート PC、タブレット) では、デスクトップ モードと タブレット モードの両方がサポートされています。

Windows 10のみ、ユーザーは [設定] [システム > タブレット モード] に移動し、[デバイスをタブレットとして使用するときに Windows をよりタッチしやすいにする] > を設定することで、タブレット モードとデスクトップ モードでの実行切り替えることができます。

public:
 static UIViewSettings ^ GetForCurrentView();
 static UIViewSettings GetForCurrentView();
public static UIViewSettings GetForCurrentView();
function getForCurrentView()
Public Shared Function GetForCurrentView () As UIViewSettings

戻り値

ビュー設定のプロパティを取得および設定するために使用できる UIViewSettings インスタンス。

ここでは、対話モードを使用して、起動時またはデバイス モードが変更されたときにアプリ レイアウトを最適化する方法を示します。

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

適用対象