WPF TextBlock Textwrapping Causes Text to be Clipped

别说谁变了你拦得住时间么 提交于 2019-12-11 02:46:59

问题


I have a WPF TextBlock which is causing the text to be clipped. The resulting text is 2 to 3 lines long. Sometimes the bottom of the first line is clipped.

Following is the XAML. The problem is with the 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>

回答1:


Setting the TextOption.TextFormattingMode to Display fixed this problem.



来源:https://stackoverflow.com/questions/23500188/wpf-textblock-textwrapping-causes-text-to-be-clipped

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