C# WPF - ScrollViewer + TextBlock Troubles


Answer :

This works:

<Window xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"         xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">     <ScrollViewer HorizontalScrollBarVisibility="Auto"                    VerticalScrollBarVisibility="Auto"                   Name="Scroller">         <TextBlock HorizontalAlignment="Stretch"                    VerticalAlignment="Stretch"                    MinWidth="100"                    Width="{Binding ElementName=Scroller, Path=ViewportWidth}"                    TextWrapping="Wrap"                    Text="Some really long text that should probably wordwrap when you resize the window." />     </ScrollViewer> </Window> 

Without more detail, the best I can do is provide the standard way of doing this. Basically, host your element (which has a minimum size) in a scroll viewer; when the scrollviewer is resized small enough such that the element cannot wholly fit inside it, it will automatically display scroll bars. Example:

<ScrollViewer>     <Button MinWidth="100" MinHeight="50"/> </ScrollViewer> 

Comments

Popular posts from this blog

Converting A String To Int In Groovy

"Cannot Create Cache Directory /home//.composer/cache/repo/https---packagist.org/, Or Directory Is Not Writable. Proceeding Without Cache"

Android How Can I Convert A String To A Editable