Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/283.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# windows phone 7中的可滚动文本块_C#_Windows Phone 7 - Fatal编程技术网

C# windows phone 7中的可滚动文本块

C# windows phone 7中的可滚动文本块,c#,windows-phone-7,C#,Windows Phone 7,我正在尝试创建一个可滚动的文本块。 但它似乎不起作用。 我该怎么做呢? 下面是我的代码: <Grid x:Name="ContentGrid" Grid.Row="1"> <ScrollViewer> <TextBlock Height="517" HorizontalAlignment="Left" Margin="33,16,0,0" Name="textBlockRules" Text="" VerticalAlignm

我正在尝试创建一个可滚动的文本块。 但它似乎不起作用。 我该怎么做呢? 下面是我的代码:

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


将scrollviewerHorizontalBar设置为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>

即使您没有明确提到,我猜您的目标是显示一些大文本而不被切碎

对于这种要求,stackoverflow上有一些有用的线程: 1. 2.


另一方面,如果您只想让文本块按顺序排列,则可以使用数据绑定到列表的列表框。

您必须设置ScrollViewer的最大高度,并可以将滚动条的可见性设置为自动

以下是来自以下方面的示例:



什么不起作用?我觉得那代码很好。添加一些文本并尝试滚动。尝试为您的
ScrollViewer
指定一个高度值。您应该设置ScrollViewer的最大高度。
<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>