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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T02:24:37+00:00 2026-05-30T02:24:37+00:00

I have an application where I have a main viewmodel whose view contains a

  • 0

I have an application where I have a main viewmodel whose view contains a tabcontrol, where each tab has its own view and viewmodel (and possibly more of them). I believe this is a pretty common design. Now, I want to open new tabs (by instantiating new viewmodels and adding them to the collection of workspaces) by firing commands from controls inside those tabs. The problem is that the command is received by the inner viewmodel, that controls the tab, not the outer one that controls the tabcontrol. What would be the best practice to do this? All the solutions I can think of are kind of “hacky” (giving the viewmodel a reference to its parent viewmodel, subscribing to a child’s event from the parent…). I am assuming there is a nice solution for this.

For example, from a “list of entities” view, clicking the “new” button or selecting a row should open another tab with an “entity details” type of view. However, the command will be received by the “list of entities” view’s viewmodel, to whom the tab is bound, and not the “list of workspaces” viewmodel to whom the tabcontrol is bound.

  • 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-30T02:24:39+00:00Added an answer on May 30, 2026 at 2:24 am

    One possibility is to have your outer viewmodel expose a command to create a new tab. We use a centralized CommandService, which is simply a dictionary of name-to-ICommand, which allows for decoupled global commands. Something like this:

    public interface ICommandService
    {
        void RegisterCommand(string name, ICommand command);
        ICommand this[string name] {get;}
    }
    
    public class OuterViewModel
    {
        public OuterViewModel (ICommandService commandService)
        {
            commandService.RegisterCommand("OpenNewTab", OpenNewTab);
        }
    
        private void OpenNewTab (object newTabViewModel)
        {
             // The new tab's viewmodel is sent as the ICommand's CommandParameter
        }
    }
    
    public class InnerViewModel
    {
        public InnerViewModel (ICommandService commandService)
        {
            _commandService = commandService; // Save injected service locally.
        }
    
        public HandleClickOnInnerTabpage()
        {
             AnotherViewModel newVM = new AnotherViewModel(...);
             _commandService["OpenNewTab"].Execute(newVM);
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have my main application delegate which contains a method that returns an object.
I have an application composed of a main view and a secondary view which
In my wpf application the main view has 5 tabs with 5 different usercontrols
In my WPF application I have 2 Windows (both Windows have their own ViewModel):
I've got a WPF application where PageItems are model objects. My main ViewModel has
I have a silverlight mvvm application that loads main view with 2 user controls
I have a TabControl and each Tab can contain the same UI but with
I have my main application ,from my main application I will be calling another
I have a main application, and a bunch of sub-applications (they are separate apps,
Events are synchronous in C#. I have this application where my main form starts

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.