xamarin / Xamarin.Forms

Xamarin.Forms is no longer supported. Migrate your apps to .NET MAUI.
https://aka.ms/xamarin-upgrade
Other
5.63k stars 1.88k forks source link

[Shell] SearchHandler not showing results when using data binding without sub-classing #5783

Open davidbritch opened 5 years ago

davidbritch commented 5 years ago

Description

I know that the main scenario for using SearchHandler is to sub-class it. However, the fact that it has ICommand properties suggests that it can be used without sub-classing, in an MVVM context.

While my bindings resolve below, and the SearchCommand executes and updates SearchResults, the search suggestions never appear:

    <Shell.SearchHandler>
        <SearchHandler x:Name="searchHandler"
                       Placeholder="Enter search term"
                       ShowsResults="true"
                       BindingContext="{Binding Source={x:Reference self}, Path=BindingContext}"
                       Command="{Binding SearchCommand}"
                       CommandParameter="{Binding Source={x:Reference searchHandler}, Path=Query, Mode=OneWay}"
                       ItemsSource="{Binding SearchResults}"
                       ItemTemplate="{StaticResource AnimalSearchTemplate}"/>
    </Shell.SearchHandler>

This problem occurs both on iOS and Android.

Note: I know there's some cruft in there that shouldn't be required eventually.

Steps to Reproduce

  1. Run the attached sample.
  2. Navigate to the Bears page (bottom tab).
  3. Search for a bear (e.g. panda). Note that the search only happens when the enter key is hit.

Expected Behavior

The search suggestions populates with the search results.

Actual Behavior

No sign of any search suggestions (it may populate but if it does it's removed very quickly).

Basic Information

Reproduction Link

Xaminals.zip

samhouts commented 5 years ago

still an issue in pre10

demoh2019 commented 3 years ago

Any Update?