如何删除一个WPF标签文本周围的边缘? [英] How can I remove the margins around text in a WPF label?

查看:153
本文介绍了如何删除一个WPF标签文本周围的边缘?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图做一个小的虚拟键盘进行标签。以下是我在XAML的键盘(但不仅仅是3项):

I am trying to make a little virtual keyboard out of labels. The following is my keyboard in XAML (but with more than just 3 keys):

<StackPanel Orientation="Vertical">
    <StackPanel Orientation="Horizontal" HorizontalAlignment="Center">
        <Border BorderThickness="1" BorderBrush="DarkGray">
            <Label Content="A" FontSize="12" MouseDown="KeyButton_Click" />
        </Border>
        <Border BorderThickness="1" BorderBrush="DarkGray">
            <Label Content="B" FontSize="12" MouseDown="KeyButton_Click" />
        </Border>
    </StackPanel>
    <StackPanel Orientation="Horizontal" HorizontalAlignment="Center">
        <Border BorderThickness="1" BorderBrush="DarkGray">
            <Label Content="C" FontSize="12" MouseDown="KeyButton_Click" />
        </Border>
    </StackPanel>
</StackPanel>

这里的问题是,有围绕在标签的文本太多的空间,使所述键盘是远大于它需要。如果我手动设置的标签,将(1)不能说明在字体和(2)将削减的信左边界一部分,而不是在顶部和差异的高度和宽度。是否有萎缩,这些利润是几乎相同大小的文本本身?

The problem with this is that there is too much space surrounding the text in the labels, causing the keyboard to be much bigger than it needs to be. If I manually set the height and width of the labels, that will (1) not account for differences in fonts and (2) will cut of part of the letter rather than the top and left margins. Is there any other way to shrink these margins to be just about the same size as the text itself?

推荐答案

使用的TextBlock 而不是标签

这篇关于如何删除一个WPF标签文本周围的边缘?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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