[英]How to scroll to specific item in ListView using triggers
I am new to triggers concepts and I'm not able to get the right approach as to how to achieve it. 我是触发概念的新手,我无法就如何实现它找到正确的方法。
Based on data I have to scroll. 基于数据,我必须滚动。 Suppose data is
cat
so in list I have to 'scroll to cat
'. 假设数据是
cat
所以在列表中我必须“滚动到cat
”。
<ViewCell Height="80">
<StackLayout Orientation="Horizontal"
HorizontalOptions="FillAndExpand"
VerticalOptions="FillAndExpand">
<Label Text="{Binding Data}"
TextColor="White"
FontSize="45"
Margin="10,5,0,0"
HorizontalOptions="CenterAndExpand"
VerticalOptions="Center">
<Label.Triggers>
<DataTrigger TargetType="Label"
Binding="{Binding Data}"
Value="true">
<Setter Property="Text"
Value="{Binding Data}" />
</DataTrigger>
</Label.Triggers>
</Label>
</StackLayout>
</ViewCell>
Based on your comments... You want to scroll to specific item in your ListView
. 根据您的评论...您想滚动到
ListView
特定项目。 First thing you need to have is a reference to that specific object in your ItemSource
list, after that using ScrollTo
method you can scroll to that specific list item in your ListView
. 首先需要引用
ItemSource
列表中的特定对象,然后使用ScrollTo
方法可以滚动到ListView
中的特定列表项。
You can try implement that like this: 您可以尝试像这样实现:
// targetObjectInListView = reference to some list item which you want to scroll to.
YourListView.ScrollTo(targetObjectInListView , ScrollToPosition.Start, true);
More about ListView.ScrollTo
you can find here . 有关
ListView.ScrollTo
更多信息,您可以在这里找到。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.