3

我试图让魅力栏在 Windows 8 中工作,但我无法使用谷歌找到任何东西。

我想要的是让用户通过魅力栏访问设置和隐私政策。

我都准备好了:

    public MainPage()
    {
        this.InitializeComponent();
        SettingsPane.GetForCurrentView().CommandsRequested += MainPage_CommandsRequested;
    }

    void MainPage_CommandsRequested(SettingsPane sender, SettingsPaneCommandsRequestedEventArgs args)
    {
        args.Request.ApplicationCommands.Add(new SettingsCommand("commandid", "Settings", DoOperation));
    }

    private async void DoOperation(IUICommand command)
    {
        //Show the Settings or Privacy Policy HERE!
    }

我不知道如何让我的设置代替://在此处显示设置或隐私政策!

任何帮助或更确切地说是代码示例都会很棒。

4

3 回答 3

4

最好将代码放在 App.xaml.cs 中,这是一个工作示例:

protected async override void OnLaunched(LaunchActivatedEventArgs args)
{ /....
   SettingsPane.GetForCurrentView().CommandsRequested += OnCommandsRequested;
   //before if (!rootFrame.Navigate(typeof...
}
void OnCommandsRequested(SettingsPane sender, SettingsPaneCommandsRequestedEventArgs args)
    {
          var privacy =  new SettingsCommand("privacyPref", "Privacy Plicy",
            (uiCommand) => { Windows.System.Launcher.LaunchUriAsync(new Uri("http://YOURURL.COM")); });
        args.Request.ApplicationCommands.Add(privacy);
        var preferences = new SettingsCommand("preferences", "Preferences", (handler) =>
        {
            var settings = new SettingsFlyout(); //Callisto extension
            settings.Content = new PreferencesUserControl(); //Add New Element->User Control
            settings.HeaderBrush = new SolidColorBrush(_background);
            settings.Background = new SolidColorBrush(_background);
            settings.HeaderText = "Preferences";
            settings.IsOpen = true;
        });
    }
于 2012-12-14T13:40:54.883 回答
0

这是App Setting的示例。

当您完全理解这一点后,您可以尝试理解此示例

这比上面的样本要好。与此示例相比,以上示例易于理解

于 2012-12-14T14:24:44.197 回答
0

关于设置/关于实现有很多问题。这是我发现的最简单的 http://blog.jerrynixon.com/2012/08/how-to-create-windows-8-settings-pane.html

于 2013-06-29T00:05:13.953 回答