在我的xamarin.forms应用程序中,我有一个Listview.The列表视图,其中包含绑定到photoURL.I的图像。我在listview.Everything worked fine.But顶部实现了一个搜索框。我现在面临的问题是,每当我搜索列表中的任何内容时,每个字符类型上的项目appears.But都会闪烁。我从API获得绑定到列表视图的数据。请参阅链接:https://gfycat.com/WaterloggedBeneficialGlobefish
我的图像绑定
<Grid>
<ci1:CircleImage
HeightRequest="200"
Source="empavatar.png"
Aspect="AspectFit">
</ci1:CircleImage>
<ci1:CircleImage
HeightRequest="200"
Source="{Binding PhotoURL}"
Aspect="AspectFit">
</ci1:CircleImage>
</Grid>当ImageURL为null时,Iam使用循环图像视图和模板图像。
我的搜索
private void SearchBar_TextChanged(object sender, TextChangedEventArgs e)
{
if (string.IsNullOrEmpty(e.NewTextValue))
{
EmployeeListView.ItemsSource = resultObjForEmployee;
}
else
{
EmployeeListView.ItemsSource = resultObjForEmployee.Where(x => x.Name.ToLower().StartsWith(e.NewTextValue));
}
}resultObjForEmployee是我从json那里得到的结果。
请帮我恢复这个问题。
发布于 2019-02-06 06:33:42
尝试将Listview的CachingStrategy设置为"RecycleElement“
<ListView CachingStrategy="RecycleElement">
<ListView.ItemTemplate>
<DataTemplate>
<ViewCell>
<Grid>
<ci1:CircleImage
HeightRequest="200"
Source="empavatar.png"
Aspect="AspectFit"></ci1:CircleImage>
<ci1:CircleImage
HeightRequest="200"
Source="{Binding PhotoURL}"
Aspect="AspectFit"></ci1:CircleImage>
</Grid>
</ViewCell>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>https://stackoverflow.com/questions/54546902
复制相似问题