Silverlight toolkit for WP7, DatePicker\TimePicker fontsize pro­blem
Asked Answered
P

2

5

I have following problem with TimePicker \ DatePicker from Silverlight Toolkit for WP7. I don't know how to change the font size in TextBox inside picker:

FontSize property:

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

changes only Header font size

Although FontFamily or FontWeight applies to both Header and TextBox. How to change FontSize in TextBox?

Here is the same question o silverlight forum

Passifloraceous answered 14/9, 2011 at 12:2 Comment(0)
O
8

This is because in their default styles, the font size is not set via TemplateBinding. See the ** part, that should do the trick. :)

    <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>
Oratorical answered 14/9, 2011 at 12:53 Comment(1)
Had to exclude PickerPageUri property then it works as expected on Windows Phone 8 SDK + Windows Phone Toolkit 4.2013 to set font size. There's another sample in windowsphone.svn.wordpress.org/trunk/WordPress/App.xaml which has template setter for TimePicker also.Matsumoto
T
0

Based on wordpress link from noxo this worked well for me :

    <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>
Touch answered 29/4, 2014 at 10:39 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.