【问题标题】:Is there an alternative to Windows 8.1 SettingsFlyout in Windows 10 UWP development?在 Windows 10 UWP 开发中是否有 Windows 8.1 SettingsFlyout 的替代方案?
【发布时间】:2016-05-09 23:58:57
【问题描述】:

我目前正在开发 Windows 10 UWP 应用程序。在升级到 Windows 10 之前,我使用了 Windows 8.1 中的 SettingsFlyout 类。现在我在 stackoverflow 上表示 Windows 10 不支持此类。

那么对于 Windows 10 UWP 中的浮出控件是否有一个很好的替代方案,它具有相同或相似的处理方式?

【问题讨论】:

  • 替代方法是使用SplitView
  • 所以我现在发现只有 SettingsPane 在我的解决方案中不起作用。飞出现在正在工作。如果我像以前一样使用它并且没有得到 Microsoft 的官方支持,那么在 Windows Store 上发布应用程序是否有问题?

标签: c# windows uwp appsettings flyout


【解决方案1】:

如果您想替换设置弹出窗口,那么有一些可能的方法
1.使用 AppBar 中的设置和导航添加 SettingsPage.xaml 页面:

<Page.TopAppBar>
    <CommandBar IsOpen="False" ClosedDisplayMode="Minimal">
        <CommandBar.PrimaryCommands>
<AppBarButton x:Name="btnSettings" Label="Settings" Click="btnSettings_Click" Icon="Setting"  >
            </AppBarButton>
        </CommandBar.PrimaryCommands>
    </CommandBar>
</Page.TopAppBar>

并实现点击事件:

 private void btnSettings_Click(object sender, RoutedEventArgs e)
    {
        this.Frame.Navigate(typeof(SettingsPage));
    }

但在这种情况下,最好添加返回按钮。
在 OnLaunched 事件结束时添加:

rootFrame.Navigated += OnNavigated;
SystemNavigationManager.GetForCurrentView().BackRequested += OnBackRequested;

并添加:

   private void OnNavigated(object sender, NavigationEventArgs e)
    {
 SystemNavigationManager.GetForCurrentView().AppViewBackButtonVisibility =
        ((Frame)sender).CanGoBack ? AppViewBackButtonVisibility.Visible : AppViewBackButtonVisibility.Collapsed;
    }

    private void OnBackRequested(object sender, BackRequestedEventArgs e)
    {
        Frame rootFrame = Window.Current.Content as Frame;

        if (rootFrame.CanGoBack)
        {
            e.Handled = true;
            rootFrame.GoBack();
        }
    }

2。还添加带有设置的 xaml 页面,但使用带有 SplitView 控件的导航并创建汉堡菜单

Windows 10 SplitView – Build Your First Hamburger Menu
Implementing a Simple Hamburger Navigation Menu

3.将设置移至ContentDialog

4.如果您没有太多设置,可以将它们放入 Flyout 控件中

<Button Content="Settings">
<Button.Flyout>
<MenuFlyout>
<ToggleMenuFlyoutItem Text="Toggle Setting" />
<MenuFlyoutSeparator />
<MenuFlyoutItem Text="Setting 1" />
<MenuFlyoutItem Text="Setting 2" />
<MenuFlyoutItem Text="Setting 3" />
</MenuFlyout>
</Button.Flyout>
</Button>

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2018-03-10
    • 1970-01-01
    • 2016-04-09
    • 2016-01-24
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多