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 6806823
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T19:45:27+00:00 2026-05-26T19:45:27+00:00

I am trying to implement MVVM in a new project (based on WPF &

  • 0

I am trying to implement MVVM in a new project (based on WPF & Prism) in which almost every screen (view) will have a search screen shown first where the user may choose to add/edit records.

The search screen takes a refernce to the VM which implements one of my interfaces ISearchProvider (which has one method IEnumerable Search(string criteria)).

Should this Search method return

  1. a collection of VM’s (with their models properly set) which will get shown in the grid in the search screen or
  2. just Models so that when the user chooses to edit a record (Model), the chosen model is given to an instance of a VM which then gets edited or
  3. some third option?
  • 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-05-26T19:45:28+00:00Added an answer on May 26, 2026 at 7:45 pm

    Whatever you plan to show to user should be wrapped with View Model.

    You mentioned that user will select model to edit. This should be view model; user will select model (entity) to edit, but what he’ll be shown (or what your view will see) should be list of view models representing some entity. User (or in this case view) should not need any knowledge of actual model.

    Now, the view model should not be doing any search itself. It should delegate search to component that’s responsibility is to perform search and return result (be it some kind of DAO, your custom tool – options may vary). What is more, the same view model should also be responsible for “feeding” view with data that may or may not arrive from search.

    To give it code example:

    public class UserListViewModel : ISearchProvider
    {
        private IUserFinder userFinder;
    
        public UserListViewModel(IUserFinder userFinder)
        {
            this.userFinder = userFinder;
        }
    
        public ObservableCollection<UserViewModel> Users { get; private set; }
    
        public void Search(string criteria)
        {
            var users = this.userFinder.Search(criteria);
            // rebuild users collection - view will get notified of any changes
            // made to .Users property as it is ObservableCollection
        }
    }
    

    Also, it’s probably good idea to make ISearchProvider interface expose single Search command. This way, binding from view is really simple.

    To sum up, 2 simple points:

    • make sure your search logic is not in view model; let view model delegate the search
    • make search results be a part of view model or actual view model objects (so you can “feed” them to view easily)
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to implement a WPF application using MVVM (Model-View-ViewModel) pattern and I'd like
I am trying to implement this MVVM pattern for the WPF form closing which
I'm trying to implement the MVVM pattern in WPF. I've followed Jeremy Alles's Very
I am trying to implement a WPF MVVM application. And I am a beginner
Being a new to WPF/XAML/MVVM, I've got a question. In my View, I have
So I've been trying to implement the MVVM pattern within a simple WPF application
I'm trying to implement IView for MVVM design pattern, which allows ViewModel to interact
I am trying to implement the MVVM design patern for mt WPF application. In
I'm using wpf + mvvm and am trying to implement a conditional converter. Here
I am new to MVVM, and I am trying to implement a simple application,

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.