Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8256813
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T01:59:13+00:00 2026-06-08T01:59:13+00:00

I have to implement a ‘global’ search/filter function in my application. Each window that

  • 0

I have to implement a ‘global’ search/filter function in my application. Each window that contains a list of information, whether it’s a DataGrid or some other implementation of a list has to have a search box, and if the user enters text in the search box, it’ll filter that list by whatever’s being searched for. I only want to implement the search logic once.

For the most part, this won’t necessarily be too difficult. The reason is that most windows that contain a list will be based on the same datatype. These are all ViewModels, and each of these ViewModels extends ViewModelBase, and ViewModelBase contains the data that I’ll be searching.

A rudimentary example:

public class ZoneVm : ViewModelBase
{
    // Zone specific functionality
}

public class UserVm : ViewModelBase
{
    // User specific functionality
}

public class ViewModelBase : INotifyPropertyChanged
{
    public string Name { get; set; }
    public int Value { get; set; }

    // The handy thing about the common view model base is that 
    // I can contain the model binding in a single place

    // It will be easy to search List<ZoneVm> and List<UserVm> because
    // they are both effectively List<ViewModelBase>. 
}

The difficulty lies in the outlier objects that I have to search. Some windows contain a list of objects that don’t extend ViewModelBase, so I won’t have this predictable list of properties to search, e.g.

public class PanelData // doesn't implement ViewModelBase :-(
{
    public int SerialNumber { get; set; }
    public Customer Customer { get; set; }

    // other properties that I'll have to search/filter on
}

Is there a ‘best practices’ approach to this kind of task? Are there design patterns that solve this problem? How should I approach having to search/filter 2 (and probably more) different kinds of list?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-08T01:59:14+00:00Added an answer on June 8, 2026 at 1:59 am

    I think you will not want to have each data to have a common searchable member?
    (this could be handeled by using a common IData-Interface with this abstract member as Ofer said)

    I would have them in a queriable collection and implement the search in an abstract fasion (please fill in the blanks yourself):

    class MySearchableDataListBase<T> : INotifyPropertyChanged
    {
       List<T> _list = new List<T>();
       string _currentFilterString = "";
    
       abstract bool FilterItemPredicate(T item, string query);
    
       public abstract IEnumerable<T> FilteredItems
       {
          get {
             return _list.Where(i => FilterItemPredicate(i, _currentFilterString)).ToArray();
          }
       }
    
       public string FilterQuery
       {
          get { return _currentFilterString; }
          set {
             if (value != _currentFilterString)
             {
                 _currentFilterString = value;
                 OnPropertyChanged("FilterQuery");
                 OnPropertyChanged("FilteredItems");
             }
          }
       }
    }
    

    You can then use this as a collection for your data and provide Commands and Properties for the filtering/searching.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In my application i have Implement to take image from Gallery. In that gallery
I have Implement Some paint like application. For that the Layout is like as
I have implement an iPhone application in jQuery mobile and Phone Gap Using list
I have to implement a sparse matrix (a matrix that has predominantly zeroes, so
I have to implement a iphone application which will record user's voice as you
I have to implement an application in which I have set small edittext for
i have implement binary search tree in c++ #include <iostream> #include <cstdlib> using namespace
I have implement game application in which i want to play mid sound file
In My Application i have Implement the Simple Gallery Demo. Here i am going
I have implement FragmentPagerAdapter in my app but it show only a same list

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.