c# - Xamarin:元素在 ScrollViewer 中被截断/未呈现
问题描述
我有以下情况。
<ScrollView BackgroundColor="DeepPink">
...
<Grid HorizontalOptions="FillAndExpand" VerticalOptions="FillAndExpand">
<ContentView Opacity="{Binding ViewProvider.IsCancelling, Converter={StaticResource BoolToOpacityConverter}}" Content="{Binding ViewProvider.CurrentView}"/>
</Grid>
...
</ScrollView>
内容视图包含多个元素,其中一个是带有 BindableLayout.ItemsSource 的 StackLayout
<StackLayout BindableLayout.ItemsSource="{Binding Rings}" Margin="12,0,0,0">
<BindableLayout.ItemTemplate>
<DataTemplate>
...
</DataTemplate>
</BindableLayout.ItemTemplate>
</StackLayout>
在视图打开时,将通过不同的操作添加环。一旦发生这种情况,ScrollViewer 的高度就会增加,但下面的部分会被截断或只是不渲染。(它减少了环使用的高度 - 我猜是因为 Grid 没有调整大小?但为什么呢?)
我尝试在添加环后调用InvalidateMeasure()和ForceLayout()但没有任何更改。有任何想法吗?
编辑
按照评论中的要求,我在 github 上上传了一个简单的演示来重现这个问题。 https://github.com/Valronicon/ScrollViewerIssue
谢谢!
编辑 2
我可以通过将 ScrollViewer 包装在一个额外的网格中来解决这个问题。不知道为什么它有效,但它有效......
解决方案
推荐阅读
- angular - 变量值在特定情况下没有更新角度?
- amazon-s3 - 队列使用者应用程序中的 OutOfMemory 错误
- c++ - 如何为 Boost::Nested_Container 实现 Boost::Serialize
- google-apps-script - 从 Gmail 电子邮件中读取消息和主题,并使用 Google Apps 脚本写入 Google 表格
- directory - 在 terraform repo 中设置多个逻辑组织的子文件夹的正确方法是什么?
- tensorflow - 每次运行都重现相同的结果 - Keras,Google Colab
- r - R中固定宽度的文本到列
- oracle - 什么是 DB2 等价于 Oracle 目录
- pentaho - Pentaho CDE 不加载控制台错误
- environment-variables - Azure DevOps - 任务组 - Visual Studio 测试任务 - 自定义测试适配器的路径 - 在以前的任务中通过脚本设置变量不起作用