c# - 如何在滚动视图 [Xamarin.Forms] 中获取当前可见项目?
问题描述
我有一个自定义控件作为滚动视图,我想扩展它,想知道我们何时处于某个项目。
public class ExtendedScrollView : ScrollView
{
public ExtendedScrollView()
{
this.Scrolled += ExtendedScrollView_Scrolled;
}
private void ExtendedScrollView_Scrolled(object sender, ScrolledEventArgs e)
{
double scrollingSpace = this.ContentSize.Height - this.Height;
if (scrollingSpace <= e.ScrollY)
{
// Hits bottom
}
}
}
我已成功找到底部,但我如何计算以查看当前可见的滚动视图中的当前视图(或视图)?
<controls:ExtendedScrollView>
<StackLayout BindableLayout.ItemsSource="{Binding service.MyList}">
<BindableLayout.ItemTemplate>
<DataTemplate>
<StackLayout>
<controls:CustomControl Data ="{Binding .}" />
<BoxView HeightRequest="1"/>
</StackLayout>
</DataTemplate>
</BindableLayout.ItemTemplate>
</StackLayout>
</controls:ExtendedScrollView>
这就是我成功将我的项目绑定到此滚动视图的方式。我更喜欢使用滚动视图,因为我对 ListView 有奇怪的问题,当我向下/向上滚动时它会卡住。
解决方案
推荐阅读
- r - 添加带有纯斜体字体的文本以进行绘图
- blockchain - Geth (go-ethereum) 在挖矿期间使用 100% CPU,即使指定了 1 个线程
- .net - 测试 TCP 端口是否在未连接的情况下打开
- amazon-web-services - 数组中的 AWS 控制台搜索
- c# - 正则表达式匹配和替换整个单词或部分单词
- reactjs - mapStateToProps 是反模式吗?
- reactjs - MSAL 以静默方式获取令牌在 IE 11 for React SPA 中不起作用
- python - django-elasticsearch 错误:[Errno -2] 名称或服务未知
- angular - Angular - 无法下载 zip 文件
- leaflet - 使用 L.vectorGrid.protobuf 绘制多多边形时遇到问题