WPF: Cutting the part of the last letter in textblock when FontStyle is Oblique

狂风中的少年 提交于 2020-01-06 04:28:15

问题


I have a simple XAML example:

<Grid>
<Button x:Name="button1" FontSize="28" FontWeight="Bold" FontStyle="Oblique" HorizontalContentAlignment="Center" Margin="296,142,296,249">
<TextBlock Width="Auto" Text="button" Padding="0" VerticalAlignment="Center"/>
</Button>
<Button x:Name="button2" Content="button" FontSize="28" FontWeight="Bold" FontStyle="Oblique" Margin="296,234,282,146" />       
</Grid>

If height of any button will changed in design mode (or added and changed property Height in xaml), the part of last letter of text in textblocks will surprisingly cut from right side.

The error is only presents on oblique font style ('italic' or 'normal' looks good). Looks like text blocks have uncorrect calculated borders of width in this case.

It can be fixed by changing Padding property (Padding="0,0,6,0"). But it's not a good practice I think.

Could anyone advice how to show oblique fontstyle text correct?

来源:https://stackoverflow.com/questions/51743565/wpf-cutting-the-part-of-the-last-letter-in-textblock-when-fontstyle-is-oblique

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!