我有 xamarin 形式的 ListView。上下滚动此 ListView 时,此时钟图像的出现和消失不一致。
即使我对可见性进行硬编码,图像也不一致。
<DataTemplate x:Key="itemTemplate">
<ViewCell>
<StackLayout Orientation="Horizontal" Spacing="5" Padding="0,0,10,0">
<Label HorizontalOptions="StartAndExpand" VerticalOptions="Center" TextColor="#455560" Text="{Binding DispenseTypeWithMachineCount}" WidthRequest="250"/>
<Image IsVisible="{Binding IsServiceInProgress}" Source="ic_progress.png" HeightRequest="24" WidthRequest="24" VerticalOptions="Center" HorizontalOptions="EndAndExpand"/>
</StackLayout>
</ViewCell>
</DataTemplate>
<ListView x:Name="ListViewAccounts" Margin="0,0,0,0" ItemsSource="{Binding ExpandedGroups}" GroupDisplayBinding="{Binding Title}" IsGroupingEnabled="true" ItemTemplate="{StaticResource accountTemplateSelector}" GroupHeaderTemplate="{StaticResource groupHeaderTemplate}">
<ListView.Behaviors>
<behaviors:EventToCommandBehavior EventName="ItemTapped" Command="{Binding Path=BindingContext.ListViewAccountItemTappedCommand Source={x:Reference ListViewAccounts}}" />
</ListView.Behaviors>
<x:Arguments>
<ListViewCachingStrategy>RecycleElement</ListViewCachingStrategy>
</x:Argume
最佳答案
您还可以更改 ListView 回收元素的方式,我注意到您正在实现它,但您的看起来很奇怪:
策略类型:
RetainElement//默认值
RecycleElement
RecycleElementAndDataTemplate
ListView :
<ListView
x:Name="ListViewAccounts"
Margin="0,0,0,0"
ItemsSource="{Binding ExpandedGroups}"
GroupDisplayBinding="{Binding Title}"
IsGroupingEnabled="true"
ItemTemplate="{StaticResource accountTemplateSelector}"
CachingStrategy="RecycleElement"
GroupHeaderTemplate="{StaticResource groupHeaderTemplate}">
<ListView.Behaviors>
<behaviors:EventToCommandBehavior
EventName="ItemTapped"
Command="{Binding Path=BindingContext.ListViewAccountItemTappedCommand, Source={x:Reference ListViewAccounts}}" />
</ListView.Behaviors>
</ListView>
关于listview - 在 ListView Xamarin 表单中滚动时图像消失,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57017480/