Skip to content

provided code sample not complete #1243

@FroggieFrog

Description

@FroggieFrog

The section about consuming the SearchHandler is incomplete.

The section above declares a property to be used as the source of the search, but it is not declared in the mentioned section.
So the IList<Animal> is always null and the AnimalSearchHandler throws an exception.

According to the sample MAUI-App, the property is bound to a static list.

But I think the more common way is to bind to the same source as the page e.g. a page containing a CollectionView with animals and that is bound to a list in a ViewModel.
There is no sample provided for this scenario. I'm really struggling to get this scenario to work due to the sparse documentation of this.

The property:

public IList<Animal> Animals { get; set; }

The sample code without binding to the property:

<ContentPage ...
             xmlns:controls="clr-namespace:Xaminals.Controls">
    <Shell.SearchHandler>
        <controls:AnimalSearchHandler Placeholder="Enter search term"
                                      ShowsResults="true"
                                      DisplayMemberName="Name" />
    </Shell.SearchHandler>
    ...
</ContentPage>

Document Details

Do not edit this section. It is required for learn.microsoft.com ➟ GitHub issue linking.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions