Reputation: 36775
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" TextTrimming="CharacterEllipsis" Text="{Binding Info}"/>
</DataTemplate>
</GridViewColumn.CellTemplate>
</GridViewColumn>
Upvotes: 1
Views: 1064
Reputation: 5975
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.
Upvotes: 2