WPF prevent TextBlock from showing multiple lines without setting the height-property
I have a textblock within a GridView that is bound to a property that contains sometimes carriage returns in the text. How can I prevent the text-block showing more than one line of text? The only solution I have found is to set the height-property but this seems to me very unproper.
I expected the following declaration to do the trick, but it does not run. Maybe I have something forgotten?
<GridViewColumn Header="Info" >
<GridViewColumn.CellTemplate>
<DataTemplate>
<TextBlock TextWrapping="NoWrap" Te开发者_StackOverflow中文版xtTrimming="CharacterEllipsis" Text="{Binding Info}"/>
</DataTemplate>
</GridViewColumn.CellTemplate>
</GridViewColumn>
One possible solution is to check the string for CR's before binding it to the TextBlock. Strip any \r and \n from the text.
精彩评论