3

I'm trying to get the charms bar working in windows 8, but i can't find any thing using google.

What i want is to let users acces settings and privacy policy throuw charms bar.

I all ready have this:

    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!
    }

I don't know how i can get my settings in place of: //Show the Settings or Privacy Policy HERE!

Any help or rather code samples would be greate.

apero
  • 1,074
  • 2
  • 23
  • 38

3 Answers3

4

It's better if you put the code in App.xaml.cs, here's a working example:

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;
        });
    }
danielrozo
  • 1,442
  • 1
  • 10
  • 22
  • Do you also have the classes for me? which you used in your example – apero Dec 14 '12 at 14:02
  • Look at the code, SettingsFlyout is in the Callisto extension and PreferencesUserControl need to be created and defined by you and put the things you want in there. – danielrozo Dec 14 '12 at 14:19
  • This worked, but i have one problem. i set this on the first page(the homescreen) and every time i go to an other page and come back to the homescreen he ads an other button to the charmsbar. is there a way to check if button is added? – apero Jan 08 '13 at 12:51
  • Don't put it on the MainPage, put it on App.xaml.cs, that's why I also put the OnLaunched method, because it needs to be in the OnLaunched method in App.xaml.cs – danielrozo Jan 08 '13 at 14:11
  • i tryed you code but the app doesn't know SettingsFlyout(); are you using some nuget packages? – apero Jan 10 '13 at 12:29
  • Check the comment on the code, SettingsFlyout is from the Callisto extension – danielrozo Jan 10 '13 at 17:16
0

Here is the sample for App Setting.

When you fully understand this you can try to understand this sample

Which is better than above sample. Above sample is easy to understand as compared to this sample

Inder Kumar Rathore
  • 39,458
  • 17
  • 135
  • 184
0

There has been quite a few questions about Settings/About implementations. This is about the easiest I have found http://blog.jerrynixon.com/2012/08/how-to-create-windows-8-settings-pane.html

Allan Nielsen
  • 260
  • 2
  • 13