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" TextTrimming="CharacterEllipsis" Text="{Binding Info}"/>                                            
        </DataTemplate>                                    
    </GridViewColumn.CellTemplate>
</GridViewColumn>

Answers


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.


Need Your Help

Get parameters value from another url

php cgi

In a .cgi file I set $HTTP_PROXY= '192.168.1.1:80' how can I get 192.168.1.1:80 from a text file on another host or url (for example line 4 data.txt in http://url.com/data.txt ).

How to extract specific part of Yaml depending on a condition?

php yaml

In the following yaml text to retrieve the names of children where exposed is true ?

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.