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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T21:09:09+00:00 2026-05-16T21:09:09+00:00

Hello fellow StackOverflow users (or Stackoverflowers ?): I’m learning-by-coding WPF. I read several articles/saw

  • 0

Hello fellow StackOverflow users (or Stackoverflowers?):

I’m learning-by-coding WPF. I read several articles/saw several screencasts, and coming from a WEB dev background, I fired up VS2010 and started doing a sample application that would help me learn the basics.

I read some about MVVM too, and started using it. I set up my solution to use WPF 4.0, ActiveRecord 2.1 and SQLite, and everything went kind well. But I still have some doubts:

  • I created a MainWindowViewModel, and am using the RelayCommand class from here to… relay the command. Am I breaking any guidelines by having a MenuItem from the MainWindow to have its command bound to a property of this viewmodel?

  • This action I’m binding the MenuItem command to is going to instantiate a new ViewModel and a new View, and show it. Again, is that ok in the MVVM context?

  • My MainWindow will be a kind of “dashboard”, and I will have more than one model attached to this dashboard. Should I just wrap all those models in a single view model?

Something like this:

public class MainWindowViewModel {

    private ObservableCollection<Order> openOrders;
    private Address deliveryAddress;
    private Order newOrder;
    /* Wrappers for the OpenOrders Collection */
    /* Wrappers for Delivery Address */
    /* Wrappers for New Order */
    /* Command Bindings */

}

TIA!

  • 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-16T21:09:12+00:00Added an answer on May 16, 2026 at 9:09 pm

    I created a MainWindowViewModel, and am using the RelayCommand class from here to… relay the command. Am I breaking any guidelines by having a MenuItem from the MainWindow to have its command bound to a property of this viewmodel?

    No, you’re not breaking any guideline. It’s perfectly appropriate to bind the MenuItem to a command of the MainWindowViewModel (where else would you put this command anyway ?)

    This action I’m binding the MenuItem command to is going to instantiate a new ViewModel and a new View, and show it. Again, is that ok in the MVVM context?

    It’s perfectly fine to create a new ViewModel, of course. As for creating a new view, it depends on how you create it… you should of course never instantiate a view explicitly from the ViewModel, because it would introduce a dependency of the VM to the view.

    My MainWindow will be a kind of “dashboard”, and I will have more than one model attached to this dashboard. Should I just wrap all those models in a single view model?

    It depends on what you mean by “wrap”… Your MainWindowViewModel could expose other ViewModels through properties, and theses VMs would be displayed in different parts of the view. If that’s what you mean, yes, you should wrap them.

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

Sidebar

Related Questions

Hello fellow Stackoverflow users, I have a page which does a AJAX request to
Hello fellow StackOverflowers. I'm have a brain fart right now, and I cannot seem
hello fellow java developers. I'm having a very strange issue. I'm trying to read
Hello fellow programmers! Recently, I started learning Git, and pretty quickly discovered the amazing
Hello stackoverflow fellow members? Struct Declaration in class A struct PointSprite { GLfloat x;
Hello fellow stackoverflowers, Most Ant build files I've seen online involve a clean target
Hello Fellow stackoverflowers, I´m stuck writing a piece of code. I have application with
Hello fellow stackoverflow-ers, I built an ajax image gallery and used asual' jquery address
Hello fellow StackOverflowers! I have some information in a database that I need pulled
Hello fellow stackoverflow family members? I know it is un-efficient to create one extra

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.