I am using a SearchBar on XamarinForm, the problem is whenever the searchbar is empty and I press the search button, the SearchCommand won't be triggered.
I tried using custom renderer on this link from xamarin forum but It does not work.
public class CustomSearchBarRenderer : SearchBarRenderer
{
protected override void OnElementChanged(ElementChangedEventArgs<SearchBar> e)
{
base.OnElementChanged(e);
if (e.OldElement == null)
{
this.Control.QueryTextSubmit += (sender, args) =>
{
if (string.IsNullOrEmpty(args.Query) && Element.SearchCommand != null)
Element.SearchCommand.Execute(null);
};
}
}
}
please help me