Silverlight 2.0 - vertical scrolling, horizontal flow

In silverlight 2.0. I have content that I want to scroll vertically and wrap horizontally. In the controls, I have a dock bar. The last child of the DockPanel that fills it is the ScrollViewer

<UserControl x:Class="MyProject.MyControl"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
    xmlns:WinControls="clr-namespace:Microsoft.Windows.Controls;
      assembly=Microsoft.Windows.Controls" 
    Width="400" Height="300">
    <WinControls:DockPanel LastChildFill="True">
    ...
<ScrollViewer x:Name="MessageScroll" HorizontalScrollBarVisibility="Hidden"
     VerticalScrollBarVisibility="Auto" BorderThickness="0" >
    <Controls:TextDisplay x:Name="TextDisplay"></Controls:TextDisplay>
</ScrollViewer>

      

The XAML TextDisplay control looks like this:

<UserControl x:Class="MyProject.TextDisplay"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
        <TextBlock x:Name="TextDisplayText" TextWrapping="Wrap">
        </TextBlock>
</UserControl>

      

What I want: TextDisplay should occupy the main control area, with a vertical scroll bar if the height doesn't fit. Messages should be wrapped when they get too long horizontally.

Scrolling works, but now messages don't right-wrap. they just cut it off. This doesn't limit the width, just hiding the HorizontalScrollBar. If I set HorizontalScrollBarVisibility = "Auto" I see that they scroll to the right. How do I make it wrap?

+1


source to share


1 answer


Try setting the HorizontalScrollBarVisibility of the ScrollViewer to Disabled (or leave it blank, since Disabled is the default), then the TextDisplay will wrap correctly and the horizontal scrollbar won't be displayed.



+4


source







All Articles