2012-12-14 46 views
3

我想獲得在Windows 8中的魅力酒吧工作,但我找不到任何使用谷歌的東西。如何在XAML,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! 
    } 

我不知道我怎麼能代替讓我的設置://此處顯示的設置或隱私政策!

任何幫助,或者更確切地說,代碼示例將是greate。

+0

我沒有得到你的問題..你能解釋你的需求和你做了什麼 –

回答

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

你也有我的課程嗎?你在示例中使用了 – apero

+0

查看代碼,SettingsFlyout位於Callisto擴展中,並且PreferencesUserControl需要由您創建和定義,並將您想要的內容放在那裏。 – danielrozo

+0

這工作,但我有一個問題。 我在第一頁(主屏幕)上設置了這個選項,每當我進入其他頁面並返回到主屏幕時,他都會向其他按鈕添加一個魅力欄。 有沒有辦法檢查按鈕是否被添加? – apero

0

這裏是App Setting樣品。

當你完全明白這一點,你可以試着去理解this sample

這與上述樣品更好。與此示例相比,以上示例很容易理解