UIViewSettings.GetForCurrentView 方法
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
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;
}
}
}