locked
help me to add setting charm how setting save and work with that RRS feed

  • Question

  • help me to add setting charm how setting save and work with that

    hi i am beginner in windows store app (C#) . i want add setting page in app . how to add settings inside the page how to work with that .

    simple program give me .

    (eg: textblock show " hello world " normal , if settings is on then show that textblok show " hello world setting is on " ) . plase help me some one , than u

    Saturday, February 8, 2014 9:56 AM

All replies

  • This is demonstrated in the documentation at Quickstart: Add app settings
    Saturday, February 8, 2014 3:01 PM
    Moderator
  • i check that but its not showing how to working , for eg: setting flyout showing toggle switch but toggle switch event handling not showing . i am crate program

    internal static class AboutPage
        {
            public static void Initialise()
            {
                SettingsPane settingsPane = SettingsPane.GetForCurrentView();
    
                settingsPane.CommandsRequested += (s, e) =>
                {
                    SettingsCommand settingsCommand = new SettingsCommand(
                      "ABOUT_ID",
                      "About",
                      command =>
                      {
                          var flyout = new SettingsFlyout();
                          flyout.Title = "About";
    
                          var version = Package.Current.Id.Version;
                          var versionstring = string.Format("{0}.{1}.{2}.{3}",
                             version.Major, version.Minor, version.Build, version.Revision);
    
                          flyout.Content = new TextBlock()
                          {
                              Text = "Created by Marius Bancila\r\nVersion " +
                                     versionstring +
                                     "\r\n\r\nThis is a demo app that shows how to work with Windows Settings Charm.",
                              TextAlignment = Windows.UI.Xaml.TextAlignment.Left,
                              TextWrapping = Windows.UI.Xaml.TextWrapping.Wrap,
                              FontSize = 14
                          };
    
                          flyout.Show();
                      }
                    );
                    e.Request.ApplicationCommands.Add(settingsCommand);
                };
            }
        }
    }


     internal static class PrivacyPolicy
        {
            public static void Initialise()
            {
                SettingsPane settingsPane = SettingsPane.GetForCurrentView();
    
                settingsPane.CommandsRequested += (s, e) =>
                {
                    SettingsCommand settingsCommand = new SettingsCommand(
                      "PRIVACY_ID",
                      "Privacy policy",
                      async command =>
                      {
                          var flyout = new SettingsFlyout();
                          flyout.Title = "Privacy policy";
    
                          var file = await StorageFile.GetFileFromApplicationUriAsync(
                             new Uri("ms-appx:///Settings/PrivacyPolicy.txt"));
                          var properties = await file.GetBasicPropertiesAsync();
                          var stream = await file.OpenAsync(FileAccessMode.Read);
                          var reader = new DataReader(stream.GetInputStreamAt(0));
                          await reader.LoadAsync((uint)properties.Size);
                          string text = reader.ReadString(reader.UnconsumedBufferLength);
    
                          flyout.Content = new TextBlock()
                          {
                              Text = text,
                              TextAlignment = Windows.UI.Xaml.TextAlignment.Left,
                              TextWrapping = Windows.UI.Xaml.TextWrapping.Wrap,
                              FontSize = 14
                          };
    
                          flyout.Show();
                      }
                    );
                    e.Request.ApplicationCommands.Add(settingsCommand);
                };
            }
        }
    }

    inside app.xaml.cs

    Window.Current.Activate();
    AboutPage.Initialise();
    PrivacyPolicy.Initialise();

    work for me but how to use button control something like a event hanling(setting flyout have a toggle switch the how to use that switch )

    Sunday, February 9, 2014 4:09 AM