简体   繁体   中英

What are some alternatives to SettingsPane in Windows 10 UWP apps?

I am porting an 8.1 metro app to Windows 10 UWP but SettingsPane is deprecated.

I know Microsoft provides guidelines online but no actual implementation advice.

I am wondering if you guys have some idea on a path forward.

I provided key chunks of code to show what I am trying to fix.

I've browsed through some other questions here and the replies all link to the guidelines posted by Microsoft.

Unfortunately this document just provides general design guidelines but no actual implementation advice.

    protected override void OnWindowCreated(WindowCreatedEventArgs args)
    {
        base.OnWindowCreated(args);
        SettingsPane.GetForCurrentView().CommandsRequested += OnCommandsRequested;
    }

    private void OnCommandsRequested(SettingsPane sender, SettingsPaneCommandsRequestedEventArgs args)
    {
        AddCommand(args, "Location", ShowConnectionSettingsFlyout);
        AddCommand(args, "UI Options", ShowUISettingsFlyout);
    }

    private void AddCommand(SettingsPaneCommandsRequestedEventArgs args, string label, UICommandInvokedHandler handler)
    {
        args.Request.ApplicationCommands.Add(new SettingsCommand(label, label, handler));
    }

Errors

1.

Severity Code Description Project File Line Suppression State Error CS1069 The type name 'SettingsPane' could not be found in the namespace 'Windows.UI.ApplicationSettings'. This type has been forwarded to assembly 'Windows, Version=255.255.255.255, Culture=neutral, PublicKeyToken=null, ContentType=WindowsRuntime' Consider adding a reference to that assembly. CycleCount C:\Users\xxxx\source\repos\CycleCount\CycleCount\App.xaml.cs 245 Active

2.

Severity Code Description Project File Line Suppression State Error CS0731 The type forwarder for type 'Windows.UI.ApplicationSettings.SettingsPaneCommandsRequestedEventArgs' in assembly 'Windows' causes a cycle CycleCount C:\Users\xxxx\source\repos\CycleCount\CycleCount\App.xaml.cs 245 Active

3.

Severity Code Description Project File Line Suppression State Error CS0103 The name 'SettingsPane' does not exist in the current context CycleCount C:\Users\xxxx\source\repos\CycleCount\CycleCount\App.xaml.cs 242 Active

Most common approach is to create a separate Settings page where you can essentially put the same XAML code as you had in the settings pane previously. Then you will need some place in your UI to put the settings button, usually this is in the NavigationView control, which even has a special area for settings, which can be shown by setting the NavigationView.IsSettingsVisible property to true . You can handle the click event on this button and navigate to the settings page.

Here are the official guidelines for app settings. In general, I would take inspiration in the Windows 10 Settings app and try to make the interface match its design at least partially, so that it is familiar to the user.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM