ListView控件/列表过滤器的Windows Phone 8.1 C# [英] ListView / List Filter Windows Phone 8.1 C#
本文介绍了ListView控件/列表过滤器的Windows Phone 8.1 C#的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个数据列表
public class PopImage
{
public async Task<List<PopImage>> PopDatas()
{
string imgfolder = "PopularImages";
var data = new List<PopImage>();
StorageFolder folder = Windows.ApplicationModel.Package.Current.InstalledLocation;
StorageFolder subfolder = await folder.GetFolderAsync(imgfolder);
var files = await subfolder.GetFilesAsync();
foreach (var items in files)
{
data.Add(new PopImage(imgfolder+"/"+items.DisplayName+ ".jpg", items.DisplayName));
}
return data;
}
public PopImage(string imagePath, string imageName)
{
ImagePath = imagePath;
ImageName = imageName;
}
public string ImagePath { get; set; }
public string ImageName { get; set; }
}
我要添加一个文本框和过滤,如果文本框TextChanged,
我需要做什么应用呢?
I want to add a textbox and filter it if textbox textchanged, what do I need to apply it?
推荐答案
您需要一个TextChanged事件添加到您的文本框。
首先在你的XAML补充一点:
You need to add a TextChanged event to your TextBox. First in your XAML add this:
<TextBox Name="tbListFilter" TextChanged="tbListFilter_TextChanged"/>
然后code后面的是:
Then the code behind is:
private void tbListFilter_TextChanged(object sender, TextChangedEventArgs e)
{
yourFilteredList = yourPopImageList.Where(p => p.ImageName.ToUpper().Contains(tbListFilter.Text.ToUpper())).ToList();
}
这篇关于ListView控件/列表过滤器的Windows Phone 8.1 C#的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文