windows-phone-7 - 当内容高度 > 2000px 时 WP7 ScrollViewer Bug

标签 windows-phone-7 xaml windows-phone scrollviewer

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

我是这样使用的:

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

   

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

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

这个错误也发生在 Width 上。

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

post是同样的问题,没有任何修复。


测试完整的 xaml 是:

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

最佳答案

如果它只是一个文本,您可以使用这个自定义控件:scrollable textblock .否则,将您的内容分成大小 < 2048 的 block 。

更新:

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

例如:

<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 像素高度的矩形一个放在另一个上面看起来不错。

第二个示例使用 StackPanel 显示 4000px 区域,它也有效

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

关于windows-phone-7 - 当内容高度 > 2000px 时 WP7 ScrollViewer Bug,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8573038/

相关文章:

c# - 在 WPF 中手动添加对 TextBox 的引用

wpf - 扩展器标题文本对齐

c# - 在 ListView 的 gridview 中使用空格/输入选中/取消选中复选框 - wpf

c# - 在 Pivot 中使用 WebBrowser 时在生产中崩溃

windows-phone-7 - 当单击 ApplicationBar 中的按钮时,来自 TextBox 的两种方式数据绑定(bind)不会更新

c# - 如何正确处理网页浏览器控件的后退导航

jquery - 动态包含 cordova.js 文件在 Windows Phone 7 中不起作用?

c# - 换行替换 c#?

c# - 以编程方式更改应用栏图标

windows-phone-8 - 如何在 WP8 应用程序中创建类似 UI 的 Tiles?