I am working on a ListView n Xamarin.Forms which includes Tools. The user should be able to search for the kind of tool and tool location. My code works just fine if you first type in both search criteria. After that you can perform a new search leaving out e.g the tool location, also working fine. But if you start by just typing in one criteria, the application stops. Doesn't make any sense to me as it seems to work after putting in both criteria. Can anyone tell me what i'm missing here?
private void Btn_Search_Clicked(object sender, EventArgs e)
{
var container = BindingContext as ToolViewModel;
var searchValueToolDescription = SfEntry_ToolType.Text;
var searchValueToolLocation = SfEntry_ToolLocation.Text;
var searchValueToolPrice = SfEntry_ToolPrice.Text;
listTools.BeginRefresh();
listTools.ItemsSource = container.Tools.Where(i =>
i.ToolDescription.Contains(searchValueToolDescription) &&
i.ToolLocation.Contains(searchValueToolLocation));
}