2011-08-05 9 views
6

スクロール可能なテキストブロックを作成しようとしています。 しかし、それは動作しないようです。 どうすればいいですか?ウィンドウ内のスクロール可能なテキストブロック7

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

+1

働いていませんか?そのコードは私にとってはうまく見えます。テキストを追加してスクロールしてみてください。 – keyboardP

+0

スクロールすることはできません –

+1

'ScrollViewer'に高さの値を与えてみてください。 – keyboardP

答えて

-1

設定scrollviewerHorizo​​ntalBar、visibal textbokストレッチをすると、あなたのテキストが十分な長さを確認して、このようなものにする:でもあなたかかわら

<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> 
+0

なぜそれはちょうど仕事をしないのですか –

+0

ScrollViewerの最大の高さを設定する必要があります。 – Anheledir

2

以下 は私のコードです明示的には言及していませんでしたが、私はあなたの目的は、切り刻まずに大きなテキストを表示することだと推測しています。

は、このような要件についてのStackOverflowに役立つのスレッドがあります:あなたが望むすべてが順番にテキストブロックを持っている場合は一方 1. Need to show large amount of text on windows phone 7 screen 2. Programmatically determining max fit in textbox (WP7)

は、あなたがそのリストボックスを使用することができますリストにデータバインドされています。

1

ScrollViewerの最大高さを設定する必要があり、スクロールバーのVisibilityをAutoに設定することができます。ここで

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>