我已经像这样定义了 4 个 ToggleSwitch(从示例中复制)。我必须使用 DataTemplate 吗?现在我想更改 TimePicker 中的时间值。如何访问 time_picker 并更改内容?非常感谢!
<toolkit:ToggleSwitch Name="sleep_mode" Grid.Row="1" Header="{Binding Path=LocalizedResources.Sleep_Mode, Source={StaticResource LocalizedStrings}}" Checked="fetch_sleepmode_Checked" Unchecked="fetch_sleepmode_UnChecked" Click="OnClicked">
<toolkit:ToggleSwitch.HeaderTemplate>
<DataTemplate>
<ContentControl FontSize="{StaticResource PhoneFontSizeLarge}" Foreground="{StaticResource PhoneForegroundBrush}" Content="{Binding}"/>
</DataTemplate>
</toolkit:ToggleSwitch.HeaderTemplate>
<toolkit:ToggleSwitch.ContentTemplate>
<DataTemplate>
<StackPanel>
<StackPanel Orientation="Horizontal">
<TextBlock Text="{Binding Path=LocalizedResources.Status, Source={StaticResource LocalizedStrings}}" FontSize="{StaticResource PhoneFontSizeSmall}"/>
<ContentControl HorizontalAlignment="Left" FontSize="{StaticResource PhoneFontSizeSmall}" Content="{Binding}"/>
</StackPanel>
<TextBlock Text="{Binding Path=LocalizedResources.SleepMode, Source={StaticResource LocalizedStrings}}" TextWrapping="Wrap" FontSize="{StaticResource PhoneFontSizeSmall}" Foreground="{StaticResource PhoneSubtleBrush}" Width="360"/>
**<toolkit:TimePicker x:Name="time_picker" ValueChanged="TimePicker_ValueChanged"/>**
</StackPanel>
</DataTemplate>
</toolkit:ToggleSwitch.ContentTemplate>
</toolkit:ToggleSwitch>