WP7 ScrollViewer 错误,当内容高度 >2000 像素 [英] WP7 ScrollViewer Bug When Content Height > 2000px

查看:49
本文介绍了WP7 ScrollViewer 错误,当内容高度 >2000 像素的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的项目中,我使用 ScrollViewer 来显示一些长的高度信息.

In my project, I use ScrollViewer to show some long height infomation.

我是这样使用的:

<Grid Grid.Row="1" Height="630">
     <ScrollViewer Background="Red" Grid.Row="1">
         <Grid>
             <Rectangle Height="3000" Fill="LightBlue" Width="440"/>
          </Grid>
     </ScrollViewer>
</Grid>

但是,不幸的是,当 scrollView 栏的垂直高度 > 2000 时,矩形没有完全显示.

But,unfortunately, the rectagnle don't show completely when scrollView bar's vertical height > 2000.

我测试过没有Grid作为ScrollViewer的内容,只有Rectangle,结果是一样的.

I have tested without Grid as ScrollViewer's content, only with Rectangle, the result is the same.

错误也发生在宽度上.

您知道解决方法是什么吗?怎么处理?

Any you have any idea what's the workaround? how to deal with it?

这个帖子是同样的问题,没有任何修复.

This post is the same issue without any fixs.

先谢谢了!-吉米

测试完整的xaml是:

The test full xaml is :

<Grid x:Name="LayoutRoot" Background="Transparent">
    <Grid.RowDefinitions>
        <RowDefinition Height="Auto"/>
        <RowDefinition Height="*"/>
    </Grid.RowDefinitions>

    <StackPanel x:Name="TitlePanel" Grid.Row="0" Margin="12,17,0,28">
        <TextBlock x:Name="ApplicationTitle" Text="MY APPLICATION" Style="{StaticResource PhoneTextNormalStyle}"/>
        <TextBlock x:Name="PageTitle" Text="page name" Margin="9,-7,0,0" Style="{StaticResource PhoneTextTitle1Style}"/>
    </StackPanel>

    <Grid Grid.Row="1" Height="630">
        <ScrollViewer Background="Red" Grid.Row="1">
            <Grid>
                <Rectangle Height="3000" Fill="LightBlue" Width="440"/>
            </Grid>
        </ScrollViewer>
    </Grid>
</Grid>

推荐答案

如果它只是一个文本,你可以使用这个自定义控件:可滚动文本块.否则,将您的内容分成大小小于等于的块.2048.

If it just a text, you could use this custom control: scrollable textblock. Otherwise, divide your content into blocks with size < 2048.

更新:

2048px 是 GPU 缓存图形的限制.您可以在滚动查看器中使用大量控件(<2048)(总数 > 2048).在某些情况下一切都很好,但在某些情况下则不然

2048px is a limit for GPU cached graphics. You can use a lot of controls (< 2048) inside a scrollviewer (total > 2048). In some cases all is fine, but in some it doesn't

例如:

<ScrollViewer Background="#4FFF6060">
    <Grid Background="#FFFF8A8A" Width="240" HorizontalAlignment="Left" d:LayoutOverrides="Height">
        <Rectangle Fill="Blue" Height="4000" VerticalAlignment="Top" Width="120" HorizontalAlignment="Left"/>
        <Rectangle Fill="Red" Height="2000" VerticalAlignment="Top" Width="120" HorizontalAlignment="Right"/>
        <Rectangle Fill="Red" Height="2000" VerticalAlignment="Top" Width="120" HorizontalAlignment="Right" Margin="0,2000,0,0"/>
    </Grid>
</ScrollViewer>

在这种情况下,蓝色矩形裁剪为 2048 像素,但两个高度为 2000 像素的矩形放在另一个上方看起来不错.

In this case blue rectangle cropped at 2048px, but two rectangles with 2000px height placed one above the other looks fine.

第二个例子使用 StackPanel 来显示 4000px 区域,它也能工作

The second example uses StackPanel to show 4000px area and it works too

<StackPanel Background="#FFFF8A8A" HorizontalAlignment="Right" Width="240" d:LayoutOverrides="Height">
    <Rectangle Fill="#FF88FF00" Height="2000" Width="240" HorizontalAlignment="Right"/>
    <Rectangle Fill="#FF88FF00" Height="2000" VerticalAlignment="Top" Width="240" HorizontalAlignment="Right"/>
</StackPanel>

这篇关于WP7 ScrollViewer 错误,当内容高度 >2000 像素的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆