locked
how to app setting RRS feed

  • Question

  • <Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
            <TextBlock x:Name="dititalclock" HorizontalAlignment="Left" TextWrapping="Wrap" VerticalAlignment="Top" Height="323" Width="1216" Margin="75,245,0,0" FontSize="200" FontFamily="Digital-7" Foreground="#FFEA1414"/>
    
        </Grid>

    public sealed partial class MainPage : Page
        {
    
            DispatcherTimer timer = new DispatcherTimer();
            public MainPage()
            {
                this.InitializeComponent();
                timer.Interval = TimeSpan.FromMilliseconds(1);
    
                timer.Tick += timer_Tick;
                timer.Start();
            }
    
            void timer_Tick(object sender, object e)
            {
    
                DateTime mytime = DateTime.Now;
                string time12 = mytime.ToString("hh:mm:ss tt"); // time 12 hours
                string time24 = mytime.ToString("HH:mm:ss");   //  time 24 hours
    
                dititalclock.Text = time12;
    
            }
    <SettingsFlyout
        x:Class="ClockTest.SettingsFlyout1"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:local="using:ClockTest"
        xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
        mc:Ignorable="d"
        IconSource="Assets/SmallLogo.png"
        Title="SettingsFlyout1"
        d:DesignWidth="346">
    
        <!-- This StackPanel acts as a root panel for vertical layout of the content sections -->
        <StackPanel VerticalAlignment="Stretch" HorizontalAlignment="Stretch" >
    
            <!-- The StackPanel(s) below define individual content sections -->
    
            <!-- Content Section 1-->
            <StackPanel Style="{StaticResource SettingsFlyoutSectionStyle}">
    
                <!-- Section 1 header -->
    
                <!-- Section 1 body -->
    
            </StackPanel>
            <TextBlock TextWrapping="Wrap" Text="24 Hours" Height="28" FontSize="25"/>
            <ToggleSwitch x:Name="utctime24" Header="ToggleSwitch" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Height="88" Width="187"/>
    
            <!-- Define more Content Sections below as necessary -->
    
        </StackPanel>
    </SettingsFlyout>
    

      public sealed partial class SettingsFlyout1 : SettingsFlyout
        {
            public SettingsFlyout1()
            {
                this.InitializeComponent();
    
            }
    
        }

     added a togle switch . that togle switch 24 hours display .
    Sunday, February 2, 2014 11:24 AM

Answers

  • use:

    ApplicationData.Current.LocalSettings.Values["Use24H"] = true / false;

    in your Tick event handler you can check the value


    Microsoft Certified Solutions Developer - Windows Store Apps Using C#

    Sunday, February 2, 2014 11:22 AM

All replies

  • use:

    ApplicationData.Current.LocalSettings.Values["Use24H"] = true / false;

    in your Tick event handler you can check the value


    Microsoft Certified Solutions Developer - Windows Store Apps Using C#

    Sunday, February 2, 2014 11:22 AM
  • i am beginner in windows store app . i want to use setting page .

    i am created app that a digital clock . normal app started it show 12 hours mode . setting page i want a togle switch . if switch is on time display 24 hours mode .

    my code is here


    DispatcherTimer Timer1 = new DispatcherTimer();
            DateTime display_time = DateTime.Now;
            public MainPage()
            {
                this.InitializeComponent();
                Timer1.Interval = TimeSpan.FromMilliseconds(1);
                Timer1.Tick += time_;
                Timer1.Start();
            }

            void time_(object sender, object e)
            {
                string time_12_hours = display_time.ToString("hh:mm:ss tt"); // time 12 hours
                string time24 = display_time.ToString("HH:mm:ss"); // time 24 hours
                timetxt.Text = string.Empty;
                timetxt.Text = time_12_hours;

            }


     <Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
            <TextBlock x:Name="timetxt" HorizontalAlignment="Left" TextWrapping="Wrap" VerticalAlignment="Top" Height="537" Width="1366" FontSize="300" FontFamily="Digital-7" Margin="0,231,0,0" Foreground="#FFE42525"/>

        </Grid>


    Setting page

     public sealed partial class SettingsFlyout1 : SettingsFlyout
        {
            public SettingsFlyout1()
            {
                this.InitializeComponent();

            }



    <!-- This StackPanel acts as a root panel for vertical layout of the content sections -->
        <StackPanel VerticalAlignment="Stretch" HorizontalAlignment="Stretch" >

            <!-- The StackPanel(s) below define individual content sections -->

            <!-- Content Section 1-->
            <StackPanel Style="{StaticResource SettingsFlyoutSectionStyle}">

                <!-- Section 1 header -->

                <!-- Section 1 body -->

            </StackPanel>
            <TextBlock TextWrapping="Wrap" Text="24 Hours" Height="28" FontSize="25"/>
            <ToggleSwitch x:Name="timemodechange" Header="ToggleSwitch" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Height="88" Width="187" Toggled="utctime24_Toggled"/>

            <!-- Define more Content Sections below as necessary -->

        </StackPanel>
    </SettingsFlyout>


    i checked lot of sample program and book they showed

    where to put this code how to work with and save that setting ,  i am beginner

    first register the event , where register event

    SettingsPane.GetForCurrentView().CommandsRequested += OnSettingsPaneCommandRequested;

    event implementation where

    private void OnSettingsPaneCommandRequested(SettingsPane sender,
                                                SettingsPaneCommandsRequestedEventArgs args)

    { // Add the commands one by one to the settings panel args.Request.ApplicationCommands.Add(new SettingsCommand("commandID", "Command Name", DoOperation));} private void DoOperation(IUICommand command){

    // Write the logic here that you want to do, when the user clicks it

    }











    Tuesday, February 4, 2014 5:49 AM