在Windows 10 UWP应用程序中,有哪些设置窗格的替代方案



我正在将8.1 metro应用程序移植到Windows 10 UWP,但SettingsPane已被弃用。

我知道微软在网上提供指导方针,但没有实际的实施建议。

我想知道你们是否对前进的道路有一些想法。

我提供了关键的代码块来显示我试图修复的内容。

我在这里浏览了其他一些问题,回复都链接到了微软发布的指导方针。

不幸的是,本文档只提供了一般的设计指南,但没有实际的实施建议。

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

错误

1.

严重性代码描述项目文件行禁止显示状态错误CS1069在命名空间"Windows.UI.ApplicationSettings"。此类型已被转发到程序集"Windows,版本=255.255.255.255,区域性=中性,PublicKeyToken=null,ContentType=WindowsRuntime请考虑添加对该程序集的引用。CycleCount C:\Users\xxxx\source\repos\CycleCount\CycleCount \App.xaml.cs 245活动

2.

严重性代码描述项目文件行禁止显示状态错误CS0731类型的类型转发器'Windows.UI.ApplicationSettings.SettingsPaneCommandsRequestedEventArgs'在程序集"Windows"中导致CycleCycleCount C:\Users\xxxx\source\repos\CycleCount\CycleCount \App.xaml.cs 245活动

3.

严重性代码描述项目文件行禁止显示状态错误CS0103当前文件中不存在名称"SettingsPane"context CycleCount C:\Users\xxxx\source\repos\CycleCount\CycleCount \App.xaml.cs 242活动

最常见的方法是创建一个单独的"设置"页面,您可以在其中放置与以前在设置窗格中相同的XAML代码。然后,您需要在UI中的某个位置放置设置按钮,通常位于NavigationView控件中,该控件甚至有一个用于设置的特殊区域,可以通过将NavigationView.IsSettingsVisible属性设置为true来显示该区域。您可以处理此按钮上的单击事件并导航到设置页面。

以下是应用程序设置的官方指南。一般来说,我会从Windows 10设置应用程序中获得灵感,并尝试使界面至少部分匹配其设计,以便用户熟悉。

相关内容

最新更新