c# - 如何让Windows 8.1应用程序进入可视状态?

标签 c# xaml windows-store-apps

我尝试将我的应用程序从 Windows 8 重新定位到 Windows 8.1。从旧版本开始,XAML 标记被保留。

<VisualStateGroup x:Name="ApplicationViewStates">
    <VisualState x:Name="FullScreenLandscape">...</VisualState>
    <VisualState x:Name="Filled">...</VisualState>
    <VisualState x:Name="FullScreenPortrait">...</VisualState>
    <VisualState x:Name="Snapped">...</VisualState>
</VisualStateGroup>

当达到一定的窗口宽度时,如何使应用程序进入一种状态?例如,当窗口宽度为 800 像素或更小时,如何激活“已捕捉”视觉状态。是否可以在不编辑此状态的 XAML 代码的情况下执行此操作?

最佳答案

使用VisualStateManager类:

VisualStateManager.GoToState(yourcontrolinstance, "FullScreenLandscape", true);

关于c# - 如何让Windows 8.1应用程序进入可视状态?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20095589/

相关文章:

xaml - 更改 VisualState 中的值

c# - Silverlight 中的单元测试私有(private)函数

c# - 是否可以将 Swagger 与 AspNetCore Odata 一起使用?

c# - 'CsGL.OSLib' 抛出异常

使用 ValidationRule 类的 WPF 验证

c# - 如何检查windowsstore应用程序中是否存在文件

winforms - 何时使用 Windows 应用商店应用程序?

c# - 在键级别合并字典,然后在值级别合并字典

xaml - 是否可以在 XAML (Xamarin.Forms) 中混合 OnIdiom 和 OnPlatform?

c# - 折叠行时动态调整数据网格列的大小