gpt4 book ai didi

c# - Windows 10 UWP 开发中是否有 Windows 8.1 SettingsFlyout 的替代方案?

转载 作者:可可西里 更新时间:2023-11-01 14:23:42 25 4
gpt4 key购买 nike

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

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

最佳答案

如果你想替换设置弹出窗口,那么有一些可能的方法
<强>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>

关于c# - Windows 10 UWP 开发中是否有 Windows 8.1 SettingsFlyout 的替代方案?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35132143/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com