The following forum(s) have migrated to Microsoft Q&A (Preview): Developing Universal Windows apps!
Visit Microsoft Q&A (Preview) to post new questions.

Learn More

 locked
Unable to change FontSize to CheckBox RRS feed

  • Question

  • In my Windows Phone project I can change the Text property of my CheckBox in the xaml file, but on the project page, nothing changes in the preview; the FontSize of my CheckBox always rest the same.

    <CheckBox Content="CheckBox" HorizontalAlignment="Left" Margin="352,115,-120,0" VerticalAlignment="Top" FontSize="12"/>

    has same FontSize Preview as :

    <CheckBox Content="CheckBox" HorizontalAlignment="Left" Margin="352,115,-120,0" VerticalAlignment="Top" FontSize="6"/>

    Can anyone help ?

    Monday, July 28, 2014 8:42 AM

All replies

  • I have had the same problem with my universal app. The default style for Checkbox is wrong. See 
    "C:\Program Files (x86)\Windows Phone Kits\8.1\Include\abi\Xaml\Design\generic.xaml".

    It defines a fixed ThemeResource for the font instead of a TemplateBinding:

    <ContentPresenter x:Name="ContentPresenter"
                      Grid.Column="1" Content="{TemplateBinding Content}"
                      ContentTemplate="{TemplateBinding ContentTemplate}"
                      Margin="{TemplateBinding Padding}"
                      HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
                      VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
                      Foreground="{TemplateBinding Foreground}"
                      FontFamily="{ThemeResource PhoneFontFamilyNormal}"
                      FontSize="{ThemeResource TextStyleLargeFontSize}"
                      FontWeight="Normal"
                      AutomationProperties.AccessibilityView="Raw" />

    You must create your own style derived from the default:

    <ContentPresenter x:Name="ContentPresenter"
                      Grid.Column="1" Content="{TemplateBinding Content}"
                      ContentTemplate="{TemplateBinding ContentTemplate}"
                      Margin="{TemplateBinding Padding}"
                      HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
                      VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
                      Foreground="{TemplateBinding Foreground}"
                      FontFamily="{TemplateBinding FontFamily}"
                      FontSize="{TemplateBinding FontSize}"
                      FontWeight="Normal"
                      AutomationProperties.AccessibilityView="Raw" />
                           

    Then you can specify any font size:

    <CheckBox Style="{StaticResource MyCheckBoxStyle}"
    FontSize="{StaticResource MyContentFontSize}"
    Content="Check box text" />


    PaulBiz

    • Proposed as answer by PaulBiz Friday, November 21, 2014 8:10 AM
    Friday, October 24, 2014 10:53 AM
  • Could you elaborate on how to implement this derived style I cant seem to get it right.
    Wednesday, February 25, 2015 1:52 AM