Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Scrollable textblock in windows phone 7

I am trying to create a scrollable text block. But it dont seem to works. How should i go about doing it? Below is my code:

    <Grid x:Name="ContentGrid" Grid.Row="1">
        <ScrollViewer>
        <TextBlock Height="517" HorizontalAlignment="Left" Margin="33,16,0,0" Name="textBlockRules" Text="" VerticalAlignment="Top" Width="414" FontSize="25" TextWrapping="Wrap" /></ScrollViewer>   

like image 836
beny lim Avatar asked Aug 05 '11 03:08

beny lim


2 Answers

Even though you didn't mention explicitly, I'm guessing that your aim is to show some large text without getting chopped.

For such a requirement there are helpful threads on stackoverflow: 1. Need to show large amount of text on windows phone 7 screen 2. Programmatically determining max fit in textbox (WP7)

On the other hand, if all you want is have text blocks in a sequence, you can use a ListBox that is databound to a list.

like image 194
moonlightdock Avatar answered Oct 02 '22 08:10

moonlightdock


You have to set the maximum height of the ScrollViewer and could set the Visibility for the Scrollbars to Auto.

Here is the example from the msdn:

<ScrollViewer Height="200" Width="200" HorizontalScrollBarVisibility="Auto" Canvas.Top="60" Canvas.Left="340">
<TextBlock Width="300" TextWrapping="Wrap" 
    Text="I am the very model of a modern Major-General, I've information vegetable, animal, and mineral, I know the kings of England, and I quote the fights historical, From Marathon to Waterloo, in order categorical; I'm very well acquainted, too, with matters mathematical, I understand equations, both the simple and quadratical, About binomial theorem I'm teeming with a lot o' news, With many cheerful facts about the square of the hypotenuse." />
</ScrollViewer>
like image 40
Anheledir Avatar answered Oct 02 '22 09:10

Anheledir