更改FontSize时CheckBox文本的对齐问题 [英] Alignment issue with CheckBox's text while changing its FontSize

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

问题描述

在我的应用程序中,我在以下代码示例中添加了更多具有各种字体大小的CheckBox控件

In my application, I have added the more number of CheckBox controls with various font size as per in the following code examples

<StackPanel Orientation="Horizontal">
        <CheckBox Content="CheckBox1"  FontSize="10"/>
        <CheckBox Content="CheckBox2"   FontSize="12"/>
        <CheckBox Content="CheckBox3"   FontSize="14"/>
        <CheckBox Content="CheckBox4"   FontSize="20"/>
        <CheckBox Content="CheckBox5"   FontSize="25"/>
    </StackPanel>

我尝试过更改VerticalContentAlignment的中心选项,但尝试了同样的渲染问题。

I have tried the workaround like by changing the Center option for VerticalContentAlignment.But same rendering issue occurred.

请检查此问题并向我们更新可能的解决方案。

Please check this issues and update the possible solution to us.

问候,

Hemalatha

Hemalatha
















推荐答案

Hello  Hemalatha,

Hello Hemalatha,

如果我理解正确,你的意思是CheckBox5不是你想要的渲染,我是对的吗? ?

If I understand correctly, you mean the CheckBox5 is not render like you want, am I right on this?

如果是这样,问题是由于不同的字体大小计算问题。你会发现当你使用25个字体到CheckBox5时,CheckBox5的大小明显比其他CheckBox大。要解决此问题,您可以将所有复选框扩展为更大的
大小。喜欢:

If so, the problem is due to different fontsize caculating issue. You will find that when you use 25 fontsize to CheckBox5, the size of CheckBox5 is obviously bigger then other CheckBox. To fix this issue, you can extend all your checkboxs to a bigger size. Like:

 <StackPanel Orientation="Horizontal"> 
            <CheckBox Content="CheckBox1" x:Name="cb1"  FontSize="10" Height="60" />
            <CheckBox Content="CheckBox2" x:Name="cb2"  FontSize="12" Height="60" />
            <CheckBox Content="CheckBox3" x:Name="cb3"  FontSize="14"  Height="60" />
            <CheckBox Content="CheckBox4" x:Name="cb4"  FontSize="20"  Height="60" />
            <CheckBox Content="CheckBox5" x:Name="cb5"  FontSize="45"  Height="60" />
        </StackPanel>

通过这种方式,它们可以毫无问题地对齐。

In this way, they are aligned without problem.

祝你好运,

Barry


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

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