2016-10-27 12 views
0

私はWindows Phone 8.1でTimePickerControlの時刻をフォーマットする方法は?

<TimePicker Time="{Binding SelectedTime, Mode=TwoWay}" HorizontalContentAlignment="Center" 
        Style="{StaticResource TimePickerStyle}" x:Name="SeekTimePicker" /> 

としてXAMLで時間ピッカーコントロールを持っているし、コントロールのが

<Style x:Key="TimePickerStyle" TargetType="TimePicker"> 
     <Setter Property="FontFamily" Value="{ThemeResource PhoneFontFamilyNormal}" /> 
     <Setter Property="FontSize" Value="{ThemeResource ContentControlFontSize}" /> 
     <Setter Property="Foreground" Value="{ThemeResource TimePickerForegroundThemeBrush}" /> 
     <Setter Property="HorizontalAlignment" Value="Stretch" /> 
     <Setter Property="HorizontalContentAlignment" Value="Left" /> 
     <Setter Property="Template"> 
      <Setter.Value> 
       <ControlTemplate TargetType="TimePicker" > 
        <StackPanel x:Name="LayoutRoot" Margin="{TemplateBinding Padding}" Background="Red"> 
         <ContentPresenter x:Name="HeaderContentPresenter" 
           ContentTemplate="{TemplateBinding HeaderTemplate}" 
           Content="aaaa" Margin="0,0,0,-3" 
           Style="{StaticResource HeaderContentPresenterStyle}" /> 
         <Button x:Name="FlyoutButton" BorderBrush="{TemplateBinding Foreground}" BorderThickness="1" 
           Foreground="{TemplateBinding Foreground}" HorizontalAlignment="Stretch" 
           HorizontalContentAlignment="{TemplateBinding HorizontalContentAlignment}" 
           IsEnabled="{TemplateBinding IsEnabled}" Padding="6.5,0,0,3" Content="qqqqqqqqqqqq" Background="Green"/> 
        </StackPanel> 
       </ControlTemplate> 
      </Setter.Value> 
     </Setter> 
    </Style> 

ある今、それは次のようになります。

enter image description here

しかし、私はそれをフォーマットしたいですとして:

0123これは以下のようにタイムピッカーのスタイル内のテンプレートを編集して

答えて

0

行うことができます

 <Style x:Key="TimePickerStyle" TargetType="TimePicker"> 
     <Setter Property="FontFamily" Value="{ThemeResource PhoneFontFamilyNormal}" /> 
     <Setter Property="FontSize" Value="{ThemeResource ContentControlFontSize}" /> 
     <Setter Property="Foreground" Value="{ThemeResource TimePickerForegroundThemeBrush}" /> 
     <Setter Property="HorizontalAlignment" Value="Stretch" /> 
     <Setter Property="HorizontalContentAlignment" Value="Left" /> 
     <Setter Property="Template"> 
      <Setter.Value> 
       <ControlTemplate TargetType="TimePicker"> 
        <StackPanel x:Name="LayoutRoot" Margin="{TemplateBinding Padding}"> 
         <ContentPresenter x:Name="HeaderContentPresenter" 
           ContentTemplate="{TemplateBinding HeaderTemplate}" 
           Content="{TemplateBinding Header}" Margin="0,0,0,-3" 
           Style="{StaticResource HeaderContentPresenterStyle}" /> 
         <Button x:Name="FlyoutButton" BorderBrush="{TemplateBinding Foreground}" BorderThickness="1" 
           Foreground="{TemplateBinding Foreground}" HorizontalAlignment="Stretch" 
           HorizontalContentAlignment="{TemplateBinding HorizontalContentAlignment}" 
           IsEnabled="{TemplateBinding IsEnabled}" Padding="6.5,0,0,3" > 
          <Button.ContentTemplate> 
           <DataTemplate> 
            <TextBlock Text="{Binding ElementName=FlyoutButton,Path=DataContext.SelectedTimeText}"/> 
           </DataTemplate> 
          </Button.ContentTemplate> 
         </Button> 
        </StackPanel> 
       </ControlTemplate> 
      </Setter.Value> 
     </Setter> 
    </Style> 
関連する問題