如何从一个WPF TextBlock的消除额外的填充? [英] How to remove additional padding from a WPF TextBlock?

查看:670
本文介绍了如何从一个WPF TextBlock的消除额外的填充?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在默认情况下一个WPF 的TextBlock 似乎也应用其他的顶部填充。我想并非如此

By default a WPF TextBlock seems to have additional top padding applied. I wish this wasn't so.


  • 我试过设置负填充,但有一个例外: 0 ,-10,0,0'不是属性的有效值填充。

我试过设置 LineHight 财产,没有明显效果。

I've tried setting the LineHight property, to no apparent effect.

这是怎么的TextBlock看起来混合。我已经标有红色的栗色有问题的部分。

This is how the TextBlock looks in Blend. I've marked the problematic portion with maroon red.

推荐答案

一些研究和的 HB 的引导我正确的答案,这是设置以下属性:

Some research and H.B. guided me to the right answer, which is setting the following properties:

<TextBlock LineStackingStrategy="BlockLineHeight"
           LineHeight="20"/> <!-- Or some other value you fancy. --> 

这篇关于如何从一个WPF TextBlock的消除额外的填充?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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