0
我在Mac机器上使用Xamarin Studio并在Xamarin Forms项目中工作。我的要求是 - 我有输入字段,输入字段的OnTextChanged事件我想只显示ListView中那些以输入文本开头的项目。对于这一刻,我正在使用以下代码来实现它 -在Xamarin Forms项目中输入文本搜索
entry_excludeIngredients.TextChanged += (s, e) => {
listof_excludeIngredients.ItemsSource = container;
if (string.IsNullOrEmpty(entry_excludeIngredients.Text))
{
listof_excludeIngredients.ItemsSource = null;
listof_excludeIngredients.IsVisible=false;
}
else
{
listof_excludeIngredients.ItemsSource = container.Where(x => x.StartsWith(entry_excludeIngredients.Text));
if(listof_excludeIngredients.ItemsSource==null)
listof_excludeIngredients.IsVisible=false;
else
listof_excludeIngredients.IsVisible=true;
}
};
但是我面临的一个问题是上面的代码区分大小写。如果输入“r”,ListView只显示以“r”开头但不以“R”开头的结果。
你是太美好了。 – Dipak
很高兴帮助:)。@ DipakAkhade –