Skip to content

Search functionality on WPF, WinUI, Maui is shared - #1830

Merged
OAzmitia merged 3 commits into
mainfrom
oscar/14282-search-wpf-winui
Aug 10, 2026
Merged

Search functionality on WPF, WinUI, Maui is shared#1830
OAzmitia merged 3 commits into
mainfrom
oscar/14282-search-wpf-winui

Conversation

@OAzmitia

@OAzmitia OAzmitia commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

Description

To improve the search functionality on WPF and WinUI we abstracted the Maui search functionality to be shared between all projects. Previously, a search "dynamic gallery" would attempt to match the full string into a name or description and return no results. This PR fixes that.

Screenshot 2026-08-05 111215

Type of change

  • Sample viewer enhancement
    Changes are visible on WPF and WinUI, although underlying changes apply to all projects.

Implementation:

  1. Abstract the search functionality in the Maui project into a shared SearchEngine class in the Shared project.
  2. Added models to profile a sample into keywords and hit score
  3. Remove concrete references to the SearchResultViewModel and created a model to reflect the results.
  4. Added SearchEngine to SampleManager class.
  5. Call SearchEngine from Maui, WPF, WinUI.

Platforms tested on

  • WPF .NET 8
  • WinUI
  • MAUI WinUI
  • MAUI Android
  • MAUI iOS
  • MAUI MacCatalyst

Checklist

  • Self-review of changes
  • All changes work as expected on all affected platforms
  • There are no warnings related to changes
  • Code is commented and follows .NET conventions and standards
  • Codemaid and XAML styler extensions have been run on every changed file
  • No unrelated changes have been made to any other code or project files

@OAzmitia
OAzmitia marked this pull request as ready for review August 5, 2026 20:25
@@ -0,0 +1,36 @@
using ArcGIS.Samples.Shared.Models;

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This file is not new code, it just got moved from inside SearchViewModel

}
}
}

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was moved to a new file

/// Initializes a new instance of the <see cref="SearchManager"/> class with the provided list of samples.
/// </summary>
/// <param name="samples">The list of samples to be managed by the search engine.</param>
public SearchEngine(IList<SampleInfo> samples)

@OAzmitia OAzmitia Aug 5, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Most of the code in this file was moved from Maui search implementation, the changes happened under the SearchEngine constructor and Search method. Extra focus on those methods would cover 90% of the changes.

@imalcolm1
imalcolm1 requested a review from praveenaak August 5, 2026 21:00

@praveenaak praveenaak left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the previous version of the WPF/WinUI, searching for "Display local scene" returned the expected sample as the top result.

Image

After these changes, the same query returns a large number of results with the intended sample buried near the bottom of the list.

Image

The same search query on MAUI shows the intended sample as the top result.

image

@OAzmitia

OAzmitia commented Aug 6, 2026

Copy link
Copy Markdown
Contributor Author

In reply to this 👆 comment.

This issue concerns how search results are presented in .NET MAUI compared to WinUI/WPF applications.

Current behavior:

  • MAUI displays search results in a flat list, making it easy to sort results by descending match score.
  • WinUI/WPF displays search results grouped by category in a tree control, preserving category organization.

The search implementation is now shared across all platforms and provides a match score for each result. However, because WinUI/WPF presents results in a hierarchical tree structure, it is not straightforward to surface the highest scoring matches at the top without modifying the existing UI.

Possible Approaches

Option Description Effort
Display results in a flat list for WinUI/WPF Introduce a dedicated list control for search results, reusing the existing item template. Results would be displayed in a single list sorted by descending match score, providing behavior consistent with MAUI. Medium
Keep the current grouped view Ignore match scores for presentation purposes and continue displaying search results grouped by category in the existing tree structure. None (already done)
Add a "Top Results" section Add a new top-level tree node named Top Results that contains the highest scoring matches. Remaining results would continue to be displayed within their existing category groups. Medium

Discussion

The primary consideration is whether consistency of result ranking across platforms is more important than preserving the existing categorized navigation experience on WinUI/WPF.

The flat list approach provides the most consistent ranking experience with MAUI, while the Top Results approach attempts to balance relevance-based ranking with the existing grouped presentation model.

@praveenaak

Copy link
Copy Markdown
Collaborator

Opting for "Display results in a flat list for WinUI/WPF" would also fix this issue.

@OAzmitia

OAzmitia commented Aug 10, 2026

Copy link
Copy Markdown
Contributor Author

Updated the code to show results with highest score

WPF/WinUI Results Maui Results
image image

@imalcolm1 imalcolm1 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, thanks a bunch for implementing this!

Comment thread src/Samples.Shared/Managers/SearchEngine.cs Outdated
Comment thread src/Samples.Shared/Managers/SearchEngine.cs Outdated
Comment thread src/Samples.Shared/Managers/SearchEngine.cs Outdated
@OAzmitia
OAzmitia merged commit c402f15 into main Aug 10, 2026
2 of 5 checks passed
@OAzmitia
OAzmitia deleted the oscar/14282-search-wpf-winui branch August 10, 2026 22:58
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.

5 participants