首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >列表视图搜索- xamarin.forms上的图像闪烁

列表视图搜索- xamarin.forms上的图像闪烁
EN

Stack Overflow用户
提问于 2019-02-06 05:03:19
回答 1查看 302关注 0票数 0

在我的xamarin.forms应用程序中,我有一个Listview.The列表视图,其中包含绑定到photoURL.I的图像。我在listview.Everything worked fine.But顶部实现了一个搜索框。我现在面临的问题是,每当我搜索列表中的任何内容时,每个字符类型上的项目appears.But都会闪烁。我从API获得绑定到列表视图的数据。请参阅链接:https://gfycat.com/WaterloggedBeneficialGlobefish

我的图像绑定

代码语言:javascript
复制
 <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使用循环图像视图和模板图像。

我的搜索

代码语言:javascript
复制
   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那里得到的结果。

请帮我恢复这个问题。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2019-02-06 06:33:42

尝试将Listview的CachingStrategy设置为"RecycleElement

代码语言:javascript
复制
<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>
票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/54546902

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档