在Windows Phone 7中可滚动的文本块

6

我想要创建一个可以滚动的文本块,但是似乎不起作用。 应该如何做? 以下是我的代码:

    <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
1
尝试为您的 ScrollViewer 设置一个高度值。 - keyboardP
3个回答

2

1

您需要设置ScrollViewer的最大高度,并将滚动条的可见性设置为自动。

以下是来自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

将scrollviewerHorizontalBar设置为可见,使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>

你应该设置ScrollViewer的最大高度。 - Anheledir

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接