xamarin/Xamarin.Forms

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

Aperta

#5783 aperta il 2 apr 2019

 (2 commenti) (0 reazioni) (0 assegnatari)C# (1926 fork)batch import
a/shell :shell:e/3 :clock3:help wantedinactivep/Androidp/iOS 🍎t/bug :bug:up-for-grabs

Metriche repository

Star
 (5644 stelle)
Metriche merge PR
 (Nessuna PR mergiata in 30 g)

Descrizione

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

  • Version with issue: 4.0-pre7
  • Last known good version: N/A
  • IDE: VSMac 8.0
  • Platform Target Frameworks:
    • iOS: 12.1
    • Android: API27

Reproduction Link

Xaminals.zip

Guida contributor