无法将FontSize更改为CheckBox [英] Unable to change FontSize to CheckBox

查看:57
本文介绍了无法将FontSize更改为CheckBox的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的Windows Phone项目中,我可以在xaml文件中更改CheckBox的Text属性,但在项目页面上,预览中没有任何变化;我的CheckBox的FontSize总是保持不变。

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"的Horizo​​ntalAlignment = QUOT;左"余量= QUOT; 352115,-120,0" VerticalAlignment = QUOT;陀螺" FontSize =" 12" />

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

具有相同的FontSize预览:

has same FontSize Preview as :

< CheckBox Content =" CheckBox"的Horizo​​ntalAlignment = QUOT;左"余量= QUOT; 352115,-120,0" VerticalAlignment = QUOT;陀螺" FontSize =" 6" />

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

有人可以帮忙吗?

推荐答案

我有我的通用应用程序遇到了同样的问题。 Checkbox的默认样式是错误的。请参阅&b;
" C:\Program Files(x86)\ Windows Phone套件\8.1 \Include\abi \Xaml \Design\generic.xaml"。

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".

它定义了字体的固定ThemeResource而不是TemplateBinding:

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" />


这篇关于无法将FontSize更改为CheckBox的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆