当内容高度 > WP7 ScrollViewer 错误2000像素
在我的项目中,我使用 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
上。
您知道解决方法是什么吗?怎么处理呢?
此帖子是同一个问题没有任何修复。
测试完整的 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>
In my project, I use ScrollViewer
to show some long height infomation.
I use like this:
<Grid Grid.Row="1" Height="630">
<ScrollViewer Background="Red" Grid.Row="1">
<Grid>
<Rectangle Height="3000" Fill="LightBlue" Width="440"/>
</Grid>
</ScrollViewer>
</Grid>
But, unfortunately, the rectangle does not show completely when scrollView
bar's vertical height > 2000.
I have tested without Grid
as ScrollViewer
's content, only with Rectangle
and the result is the same.
And the bug is also happens with Width
.
Any you have any idea what's the workaround? How to deal with it?
This post is the same issue without any fixes.
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>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如果它只是文本,您可以使用此自定义控件:可滚动文本块。否则,将您的内容分成大小 < 的块。 2048.
UPD:
2048px 是 GPU 缓存图形的限制。您可以在滚动查看器中使用许多控件(< 2048)(总计> 2048)。在某些情况下一切都很好,但在某些情况下则不然。
例如:
在本例中,蓝色矩形裁剪为 2048px,但两个高度为 2000px 的矩形放置在另一个上方看起来不错。
第二个示例使用 StackPanel 显示 4000px 区域,它也有效
If it just a text, you could use this custom control: scrollable textblock. Otherwise, divide your content into blocks with size < 2048.
UPD:
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
For example:
In this case blue rectangle cropped at 2048px, but two rectangles with 2000px height placed one above the other looks fine.
The second example uses StackPanel to show 4000px area and it works too
最大限度。 WP7 上的纹理大小为 2048x2048。矩形高度超出此限制。一旦将其降低到此限制以下,它就会开始工作。
此代码更适合实验,因为您可以识别底部边框:
一旦增加边框高度,底部就会消失。
另一方面,我不得不说这种行为也让我感到惊讶。我希望系统将大对象分解为更小的纹理,但显然 WP7 设计师决定不这样做,而是明显的 UI 错误。
Max. texture size on WP7 is 2048x2048. The rectangle height exceeds this limit. Once you decrease it below this limit, it starts working.
This code is better suited to experiments as you can identify bottom border:
Once you increase the Border height, the bottom part will disappear.
On the other hand, I have to say that this behavior surprises me, too. I would expect that system decomposes large objects into smaller textures, but apparently WP7 designers decided not to do so, but rather manifest UI bug.