2011-09-14 84 views
5

我從WP7的Silverlight工具包的TimePicker \ DatePicker有以下問題。我不知道如何更改字體大小在文本框內選擇器:Silverlight工具包的WP7,DatePicker TimePicker的字體大小問題

字號屬性:

<toolkit:DatePicker FontSize="30" Foreground="Black" Header="tas" Name="dpiker"/> 

變化只有標題字體大小

雖然FontFamily or Fo ntWeight適用於標題和文本框。如何更改TextBox中的FontSize?

Here is the same question o silverlight forum

回答

8

這是因爲在他們的默認樣式,字體大小不通過TemplateBinding設置。見* *部分,這應該做的伎倆。 :)

<Style TargetType="toolkit:DatePicker"> 
     <Setter Property="Background" Value="{StaticResource PhoneTextBoxBrush}"/> 
     <Setter Property="BorderThickness" Value="0"/> 
     <Setter Property="Foreground" Value="{StaticResource PhoneTextBoxForegroundBrush}"/> 
     <Setter Property="HorizontalContentAlignment" Value="Left"/> 
     <Setter Property="PickerPageUri" Value="/Microsoft.Phone.Controls.Toolkit;component/DateTimePickers/DatePickerPage.xaml"/> 
     <Setter Property="ValueStringFormat" Value="{}{0:d}"/> 
     <Setter Property="Template"> 
      <Setter.Value> 
       <ControlTemplate TargetType="toolkit:DatePicker"> 
        <StackPanel> 
         <ContentControl ContentTemplate="{TemplateBinding HeaderTemplate}" Content="{TemplateBinding Header}" Foreground="{StaticResource PhoneSubtleBrush}" HorizontalContentAlignment="{TemplateBinding HorizontalContentAlignment}" Margin="12,0,12,-4"/> 
         <Button x:Name="DateTimeButton" BorderThickness="{TemplateBinding BorderThickness}" Background="{TemplateBinding Background}" Content="{TemplateBinding ValueString}" Foreground="{TemplateBinding Foreground}" FontFamily="{TemplateBinding FontFamily}" HorizontalContentAlignment="{TemplateBinding HorizontalContentAlignment}" Height="72" **FontSize="{TemplateBinding FontSize}"**/> 
        </StackPanel> 
       </ControlTemplate> 
      </Setter.Value> 
     </Setter> 
    </Style> 
+1

這就是它!謝謝:) – szysz3kster

+1

不得不排除PickerPageUri屬性,然後按照預期在Windows Phone 8 SDK + Windows Phone Toolkit 4.2013上設置字體大小。 https://windowsphone.svn.wordpress.org/trunk/WordPress/App.xaml中還有另一個示例,它也爲TimePicker提供了模板設置器。 – noxo

0

基於從noxo WordPress的鏈接這個工作很適合我:

<Style x:Key="DatePickerStyle1" TargetType="toolkit:DatePicker" BasedOn="{StaticResource DateTimePickerStyles}"> 
     <Setter Property="Template"> 
      <Setter.Value> 
       <ControlTemplate TargetType="toolkit:DatePicker"> 
        <StackPanel> 
         <ContentControl ContentTemplate="{TemplateBinding HeaderTemplate}" Content="{TemplateBinding Header}" Foreground="{StaticResource PhoneSubtleBrush}" HorizontalContentAlignment="{TemplateBinding HorizontalContentAlignment}" Margin="12,0,12,-4"/> 
         <Button x:Name="DateTimeButton" BorderThickness="{TemplateBinding BorderThickness}" Background="{TemplateBinding Background}" Content="{TemplateBinding ValueString}" Foreground="{TemplateBinding Foreground}" FontFamily="{TemplateBinding FontFamily}" HorizontalContentAlignment="{TemplateBinding HorizontalContentAlignment}" Height="Auto" FontSize="{TemplateBinding FontSize}"/> 
        </StackPanel> 
       </ControlTemplate> 
      </Setter.Value> 
     </Setter> 
    </Style>