开发者

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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜