2013-12-21 55 views
0

我有一個代碼,它顯示隱私策略URL在魅力設置欄中。但我需要的是當用戶點擊隱私策略鏈接時,應打開另一個頁面與背部button.How魅力設置做同樣的在下面的代碼在windows應用程序中使用我的隱私頁面顯示隱私設置中的按鈕

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

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

這很容易,用代碼替換此代碼(開放URL),這將打開設置魅力的另一頁。 – crea7or

+0

我認爲你正在尋找Flyout,看看[Flyout示例](http://code.msdn.microsoft.com/windowsapps/Flyout-sample-258757b3)。 – kiewic

+0

@ crea7or我們假設我有一個名爲「Privacy.xaml」的XAML頁面,它有一個超鏈接。現在我想在設置的魅力中顯示這個頁面。我將如何調用這個頁面?並且我已經在App.xaml.cs頁面 – KhanXc

回答

0

最後我想出的解決方案,這要歸功於Windows 8.1中Appsetting示例應用程序。首先的settingsFlyout XAML頁面添加到您的project.I添加隱私彈出代碼在我的應用程序的主頁上這樣

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

感謝大家的幫助!如果有人遇到困難,只需打我;)

相關問題