2016-02-01 43 views
4

我目前正在开发一个Windows 10 UWP应用程序。在升级到Windows 10之前,我在Windows 8.1中使用了SettingsFlyout类。现在我红色的计算器上,这个类不被Windows 10支持。在Windows 10 UWP开发中是否有Windows 8.1 SettingsFlyout的替代方案?

那么,在Windows 10 UWP中具有相同或相似处理的弹出窗口是否有很好的选择?

+0

另一种方法是使用'SplitView'代替。 – Herdo

+0

所以我现在发现只有SettingsPane在我的解决方案中不起作用。弹出窗口正在工作。如果我像以前一样使用它,并且它不受Microsoft的官方支持,那么在Windows应用商店中发布应用程序是否存在问题? –

回答

1

如果你想更换设置弹出按钮然后有一些可能的方式
1.设置和导航添加SettingsPage.xaml页从AppBar:

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

但是在这种情况下最好添加Back按钮。
在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.如果你没有太多的设置,你可以把它们放到弹出按钮控制

<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> 
相关问题