我有一个WPF TextBlock导致文本被剪裁。生成的文本长度为2到3行。有时第一行的底部会被剪裁。
以下是XAML。问题出在TextBlock上:
<Grid x:Name="background">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" />
<ColumnDefinition />
<ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions>
<Rectangle Width="24"
Height="24"
Margin="10,5"
Fill="{StaticResource ExclaimationIcon}" />
<TextBlock Grid.Column="1"
Margin="5"
VerticalAlignment="Center"
Text="{Binding Message}"
TextWrapping="Wrap" />
<Button Grid.Column="2"
Margin="5"
VerticalAlignment="Top"
Command="{Binding Clear}"
Padding="3"
Style="{StaticResource HiddenButtonStyle}"
Visibility="{Binding AllowedToClear,
Converter={StaticResource ShowOnTrue}}">
<Image Width="12" Height="12"
Source="/AppliancePluginLibrary;component/AdminComponents/Assets/Delete.png" />
</Button>
</Grid>
答案 0 :(得分:1)
将TextOption.TextFormattingMode设置为Display可修复此问题。