Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Nov 28, 2025

The SearchHandler documentation samples were incomplete—the AnimalSearchHandler.Animals property was declared but never bound, causing NullReferenceException when searching.

Changes

  • "Consume a SearchHandler" section: Added Animals="{x:Static data:CatData.Cats}" binding and required namespace declaration to both XAML and C# samples
  • "Define search results item appearance" section: Added same Animals binding and namespace declarations

Example (XAML)

<ContentPage ...
             xmlns:controls="clr-namespace:Xaminals.Controls"
             xmlns:data="clr-namespace:Xaminals.Data">
    <Shell.SearchHandler>
        <controls:AnimalSearchHandler Placeholder="Enter search term"
                                      ShowsResults="true"
                                      DisplayMemberName="Name"
                                      Animals="{x:Static data:CatData.Cats}" />
    </Shell.SearchHandler>
</ContentPage>

Aligns with the maui-samples reference implementation.

Original prompt

This section details on the original issue you should resolve

<issue_title>provided code sample not complete</issue_title>
<issue_description>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.

Comments on the Issue (you are @copilot in this section)


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

@learn-build-service-prod
Copy link

Learn Build status updates of commit 4dc4014:

✅ Validation status: passed

For more details, please refer to the build report.

@learn-build-service-prod
Copy link

PoliCheck Scan Report

The following report lists PoliCheck issues in PR files. Before you merge the PR, you must fix all severity-1 and severity-2 issues. The AI Review Details column lists suggestions for either removing or replacing the terms. If you find a false positive result, mention it in a PR comment and include this text: #policheck-false-positive. This feedback helps reduce false positives in future scans.

✅ No issues found

More information about PoliCheck

Information: PoliCheck | Severity Guidance | Term
For any questions: Try searching the learn.microsoft.com contributor guides or post your question in the Learn support channel.

@learn-build-service-prod
Copy link

Learn Build status updates of commit 9fa39b6:

✅ Validation status: passed

File Status Preview URL Details
docs/fundamentals/shell/search.md ✅Succeeded View (>=net-maui-8.0)

For more details, please refer to the build report.

@learn-build-service-prod
Copy link

PoliCheck Scan Report

The following report lists PoliCheck issues in PR files. Before you merge the PR, you must fix all severity-1 and severity-2 issues. The AI Review Details column lists suggestions for either removing or replacing the terms. If you find a false positive result, mention it in a PR comment and include this text: #policheck-false-positive. This feedback helps reduce false positives in future scans.

✅ No issues found

More information about PoliCheck

Information: PoliCheck | Severity Guidance | Term
For any questions: Try searching the learn.microsoft.com contributor guides or post your question in the Learn support channel.

Copilot AI changed the title [WIP] Fix incomplete code sample for SearchHandler in MAUI Add missing Animals property binding to SearchHandler samples Nov 28, 2025
Copilot finished work on behalf of PureWeen November 28, 2025 23:07
Copilot AI requested a review from PureWeen November 28, 2025 23:07
@learn-build-service-prod
Copy link

Learn Build status updates of commit 9fa39b6:

✅ Validation status: passed

File Status Preview URL Details
docs/fundamentals/shell/search.md ✅Succeeded View (>=net-maui-8.0)

For more details, please refer to the build report.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

provided code sample not complete

2 participants