Windows商店应用设置 [英] windows store app setting
问题描述
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;
}
<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
public sealed partial class SettingsFlyout1 : SettingsFlyout
{
public SettingsFlyout1()
{
this.InitializeComponent();
}
<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想要打开然后时间显示为24小时模式,然后12小时保存设置,如果我关闭应用程序再次启动,我保存将导致运行应用程序(如果在24小时模式下切换开关并关闭应用程序设置永久性,togle swich是12小时模式seeting永久)plase帮助或任何示例应用程序如何应用程序设置工作我不需要Windows sdk示例它只显示如何添加设置,我想如何使用该设置
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
推荐答案
尝试
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>
两个eventa将处理您的切换代码。
The two eventa will handle your toggle code.
这篇关于Windows商店应用设置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!