Textblock.TextTrimming not working inside a grid

最后都变了- 提交于 2019-12-04 03:17:46
Abe Heidebrecht

In order for this to work, you would need the last column in the second grid to have a * size, otherwise it will tell the TextBlock that it has as much space as it wants, even if it doesn't. Auto sized columns won't restrict the content to the bounds of a grid. However, you would probably get better results if you did this with a single TextBlock, and multiple Runs:

<TextBlock FontSize="18" TextTrimming="CharacterEllipsis">
    <Run Text="{Binding Path=FeedItems.Count}" FontWeight="SemiBold" />
    <Run Text=" items from " />
    <Run Text="{Binding Path=Name}" />
</TextBlock>

Note that you can only bind Run.Text as of .NET 4.0. If you're using an older version of the framework, you'll have to create your own BindableRun, which is pretty simple as seen here.

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