Click here to Skip to main content
15,902,777 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
C#
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 Use24H = mytime.ToString("HH:mm:ss");   // time 24 hours
           dititalclock.Text = time12;

       }





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

    </Grid>



Settings Page

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

       }


XML
<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>



i want to togle switch on then time display as 24 hours mode , its of then 12 hours an save the setting , if i am close the app start again whiich seeting i am saved that will deafult an run the app (if togle switch on 24 hours mode and close app it setting permanent , togle swich is of then 12 hours mode seeting permanent ) plase help or any sample app for how to app setting work i don't need windows sdk sample its only showing how to add setting , i want how to work with thatt setting
Posted
Updated 2-Feb-14 20:11pm
v3

1 solution

Try
<controls:ToggleSwitch Unchecked="ToggleNotification_Unchecked" Checked="ToggleNotification_Checked">
          <controls:toggleswitch x:name="ToggleNotification" xmlns:x="#unknown" xmlns:controls="#unknown">
                <controls:toggleswitch.headertemplate>
                    <datatemplate>
                        <contentcontrol content="{Binding}" />
                    </datatemplate>
                </controls:toggleswitch.headertemplate>
                <controls:toggleswitch.foreground>
                    <solidcolorbrush color="{StaticResource PhoneAccentColor}" />
                </controls:toggleswitch.foreground>
            </controls:toggleswitch>


The two eventa will handle your toggle code.
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900