Scrolling text block in Windows Phone 7

I am trying to create a scrollable text block . But it doesn't seem to work. How am I supposed to do this? 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> 

+6
source share
3 answers

Even if you have not explicitly indicated, I assume that your goal is to show some kind of large text without cutting.

For such a requirement, there are useful threads in stackoverflow: 1. It is necessary to show a large amount of text on the screen of Windows Phone 7 2. Programmatically determine the maximum match in a text field (WP7)

On the other hand, if everything you want has text blocks in sequence, you can use a ListBox bound to a data directory.

+2
source

You must set the maximum height of the ScrollViewer and set the visibility of the scroll bar to Auto.

Here is an example from 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> 
+1
source

Set scrollviewerHorizontalBar to visibal, stretch the text and make sure your text is long enough, something like this:

  <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> 
-1
source

Source: https://habr.com/ru/post/894343/