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