使用我的隐私页面在Windows应用商店中显示魅力设置中的后退按钮

时间:2013-12-21 21:00:36

标签: xaml windows-store-apps

我有一个代码,在魅力设置栏中显示隐私政策网址。但我需要的是,当用户点击隐私政策链接时,它应该在魅力设置中使用后退按钮打开另一个页面。如何做同样的事情以下代码

 private async void OpenPrivacyPolicy(IUICommand command)
        {     
            Uri uri = new Uri("https://sites.google.com/site/mysite/");

            await Windows.System.Launcher.LaunchUriAsync(uri);
        }

1 个答案:

答案 0 :(得分:0)

最后,我想出了解决方案,感谢windows 8.1 Appsetting示例应用程序。首先将settingsFlyout XAML页面添加到您的项目中。我在我的应用程序主页中添加了隐私弹出代码,如下所示

 protected override void OnNavigatedTo(NavigationEventArgs e)
    {
        SettingsPane.GetForCurrentView().CommandsRequested += onCommandsRequested;
    }

    protected override void OnNavigatedFrom(NavigationEventArgs e)
    {

        SettingsPane.GetForCurrentView().CommandsRequested -= onCommandsRequested;
    }
    void onCommandsRequested(SettingsPane settingsPane, SettingsPaneCommandsRequestedEventArgs e)
    {
        SettingsCommand defaultsCommand = new SettingsCommand("Privacy", "Privacy",
            (handler) =>
            {
                Privacy sf = new Privacy();
                sf.Show();
            });
        e.Request.ApplicationCommands.Add(defaultsCommand);

    }

然后在我的Privacy.xaml页面中添加了以下代码

 public Privacy()
    {
        this.InitializeComponent();
        this.Loaded += (sender, e) =>
        {
            Window.Current.CoreWindow.Dispatcher.AcceleratorKeyActivated += SettingsFlyout1_AcceleratorKeyActivated;
        };
        this.Unloaded += (sender, e) =>
        {
            Window.Current.CoreWindow.Dispatcher.AcceleratorKeyActivated -= SettingsFlyout1_AcceleratorKeyActivated;
        };
    }
    void SettingsFlyout1_AcceleratorKeyActivated(CoreDispatcher sender, AcceleratorKeyEventArgs args)
    {
        // Only investigate further when Left is pressed
        if (args.EventType == CoreAcceleratorKeyEventType.SystemKeyDown &&
            args.VirtualKey == VirtualKey.Left)
        {
            var coreWindow = Window.Current.CoreWindow;
            var downState = CoreVirtualKeyStates.Down;


            bool menuKey = (coreWindow.GetKeyState(VirtualKey.Menu) & downState) == downState;
            bool controlKey = (coreWindow.GetKeyState(VirtualKey.Control) & downState) == downState;
            bool shiftKey = (coreWindow.GetKeyState(VirtualKey.Shift) & downState) == downState;

            if (menuKey && !controlKey && !shiftKey)
            {
                args.Handled = true;
                this.Hide();
            }
        }
    }

感谢所有人的帮助!这个代码有效!如果遇到任何困难的人只是打我;)