WPF: Cutting the part of the last letter in textbl

2019-08-16 00:29发布

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.

here is an image how the cutting of letter looks

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?

0条回答
登录 后发表回答