WPF TextBlock Padding is cutting off text

独自空忆成欢 提交于 2019-12-04 05:33:03

What you describe is obviously a layout bug in WPF (probably in the TextBlock). Whether or not the last letter is wrapped (and cut off) seems to depends on the actual width of the string and the size of the last letter in respect to the size of the padding.

I suggest you report the bug here.

To work around this issue you can use the following code (just put a border around you textblock and set the padding there instead):

<Border Padding="5" Grid.Row="0" Grid.Column="1">
    <TextBlock  HorizontalAlignment="Left"
        Text="0x0F" TextWrapping="Wrap"
        VerticalAlignment="Top" />
</Border>

Make the column of the grid that contains textblock auto size like this

<Grid>
  <Grid.ColumnDefinitions>
    <ColumnDefinition Width="Auto" />
  </Grid.ColumnDefinitions>
  <TextBlock Grid.COlumn="0" Text="{Binding Path=SomeViewModelProperty}" />
</Grid>

If you set the height on the TextBlock to 100, does the F then get wrapped?

Just increase the Height of the ComboBoxItem , it should solve the problem.

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