【问题标题】:Silverlight toolkit for WP7, DatePicker\TimePicker fontsize pro­blemWP7 的 Silverlight 工具包,DatePicker\TimePicker 字体大小问题
【发布时间】:2014-04-29 18:39:55
【问题描述】:

我在使用 Silverlight Toolkit for WP7 的 TimePicker \ DatePicker 时遇到以下问题。我不知道如何在选取器内的 TextBox 中更改字体大小:

FontSize 属性:

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

仅更改标题字体大小

虽然 FontFamilyFontWeight 适用于 Header 和 TextBox。如何更改文本框中的字体大小?

Here is the same question o silverlight forum

【问题讨论】:

    标签: silverlight windows-phone-7 datepicker font-size toolkit


    【解决方案1】:

    这是因为在它们的默认样式中,字体大小不是通过 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>
    

    【讨论】:

    • 必须排除 PickerPageUri 属性,然后它可以在 Windows Phone 8 SDK + Windows Phone Toolkit 4.2013 上按预期工作以设置字体大小。 windowsphone.svn.wordpress.org/trunk/WordPress/App.xaml 中还有另一个示例,其中也有 TimePicker 的模板设置器。
    【解决方案2】:

    基于 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>
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2012-04-21
      • 2012-04-27
      • 1970-01-01
      • 2015-05-13
      • 2011-05-02
      • 1970-01-01
      • 1970-01-01
      • 2011-07-02
      相关资源
      最近更新 更多