简体   繁体   English

标签具有巨大的行距,导致 wpf 中彼此重叠

[英]labels have huge line spacing causing overlapping each other in wpf

Issue:问题:

I have a wpf application with some labels in a Grid.我有一个 wpf 应用程序,网格中有一些标签。 The Grid Row height is not set未设置网格行高度

<Grid>
    <Grid.ColumnDefinitions>
        <ColumnDefinition Width="1*"></ColumnDefinition>
        <ColumnDefinition Width="1*"></ColumnDefinition>
    </Grid.ColumnDefinitions>
    <Grid.RowDefinitions>
        <RowDefinition></RowDefinition>
        <RowDefinition></RowDefinition>
        <RowDefinition></RowDefinition>
        <RowDefinition></RowDefinition>
    </Grid.RowDefinitions>
    <Label Content="Created tickets last week:" Grid.Row="0" Grid.Column="0"></Label>
    <Label x:Name="TicketsCreatedLastWeek" Content="0" Grid.Row="0" Grid.Column="1"></Label>
    <Label Content="Target tickets per day:" Grid.Row="1" Grid.Column="0"></Label>
    <Label x:Name="TargetTicketsPerDay" Content="0" Grid.Row="1" Grid.Column="1"></Label>
    <Label Content="Tickets done Today:" Grid.Row="2" Grid.Column="0"></Label>
    <Label x:Name="TicketsDoneToday" Content="0" Grid.Row="2" Grid.Column="1"></Label>
    <Label Content="Day Ticket Progress:" Grid.Row="3" Grid.Column="0"></Label>
    <ProgressBar x:Name="TicketDayProgressbar" Grid.Row="3" Grid.Column="1"></ProgressBar>
</Grid>

within the WPF Application, it looks like this:在 WPF 应用程序中,它看起来像这样:
在此处输入图像描述

The overlapping itself is not the issue.重叠本身不是问题。 By making the form bigger, everything shows up correctly.通过使表格更大,一切都正确显示。

My main concern is the huge margin around the text.我主要担心的是文本周围的巨大空白。 There is no margin set.没有设置边距。 It appears to be 1 full line height.它似乎是 1 整行高度。
在此处输入图像描述

Question:问题:

Is there a way to reduce line spacing to 0, so that I can actually format and put margin as I please?有没有办法将行距减小到 0,以便我可以按照自己的意愿实际格式化和放置边距?

Label adds Padding around its Content (usually 5). Label 在其内容周围添加填充(通常为 5)。 Change it to whatever suits:将其更改为适合的任何内容:

<Label Content="Created tickets last week:" Padding="0" Grid.Row="0" Grid.Column="0"/>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM