Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding Controls Search Bar #661

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

harshit7962
Copy link
Contributor

@harshit7962 harshit7962 commented Oct 3, 2024

Fixes: #633

The following changes adds a search bar in WPF gallery, to check find controls.

Microsoft Reviewers: Open in CodeFlow

@harshit7962 harshit7962 added * NO MERGE * metadata: The PR is not ready for merge yet (see discussion for detailed reasons) WPF Gallery labels Oct 3, 2024
@harshit7962 harshit7962 added this to the Future milestone Oct 3, 2024
initializeMapping();
}

private void initializeMapping()
Copy link
Member

Choose a reason for hiding this comment

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

Don't do it this way. There is a ControlsInfoData.json, which is to be used to get the list of all the controls and pages. Use that.

This will reintroduce the redundancy of data.

@@ -1,5 +1,6 @@
using System.Collections;
using System.Windows.Navigation;
using WPFGallery.Views;
Copy link
Member

Choose a reason for hiding this comment

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

Navigation Service should not depend on the Views, IMO.

{
var comboBox = sender as ComboBox;

comboBox.IsDropDownOpen = true;
Copy link
Member

Choose a reason for hiding this comment

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

What is the behavior when we navigate on the drop down using arrow keys ? For A11y, we will have to avoid selection, but I am guessing that's working correctly. I will try to run the changes and check it out. Overall, good work.

@@ -12,6 +12,39 @@ public partial class MainWindowViewModel : ObservableObject
[ObservableProperty]
private string _applicationTitle = "WPF Gallery Preview";

private ObservableCollection<string> SearchItems { get; set; }
Copy link
Member

Choose a reason for hiding this comment

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

What's the need for search items ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It contains the list of all pages in string format. This is then used to filter out from this whole set without changing the original FilteredSearchItems.

}
}

private void FilterItems()
Copy link
Member

Choose a reason for hiding this comment

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

This should go in ControlsInfoDataSource.cs .


SearchItems = new();

foreach (ControlInfoDataItem mainPage in Controls)
Copy link
Member

Choose a reason for hiding this comment

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

Even this should go in ControlsInfoDataSource.cs
Reasoning being, it is not related to MainWindow, and it may be needed by multiple viewmodels.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
* NO MERGE * metadata: The PR is not ready for merge yet (see discussion for detailed reasons) WPF Gallery
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add controls and icons search functionality
2 participants