我遇到了来自Silverlight Toolkit for WP7的TimePicker \ DatePicker的问题。我不知道如何在选择器内的TextBox中更改字体大小:
FontSize属性:
<toolkit:DatePicker FontSize="30" Foreground="Black" Header="tas" Name="dpiker"/>
仅更改标题字体大小
虽然 FontFamily 或 FontWeight 适用于Header和TextBox。如何在TextBox中更改FontSize?
答案 0 :(得分: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 :(得分: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>