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

  • Home
  • SEARCH
  • 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 8412051
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T00:34:45+00:00 2026-06-10T00:34:45+00:00

I am simplifying a little here: I have a tab control, and should like

  • 0

I am simplifying a little here:

I have a tab control, and should like for individual tabs to have the power to create further tabs; siblings if you will. So I am calling the tab control the parent, and its tab pages the children.

Using MVVM, my tab control view model is something like this:

class ParentViewModel
{
    ObservableCollection<ChildViewModel> _pages;

    public ObservableCollection<ChildViewModel> Pages
    {
        get
        {
            if (_pages == null)
                _pages = new ObservableCollection<ChildViewModel>();
            return _pages;
        }
    }

    public ParentViewModel()
    {
        Pages.Add(new ChildViewModel());
    }
}

So I have a collection of ChildViewModel objects on my ParentViewModel.

This works a treat, and from inside the ParentViewModel I can of course easily add all the extra ChildViewModel objects I want to my collection and have it all nicely reflected in my Views.

What I want to do is allow a button press (for example) on a ChildView to result in the addition of another ChildViewModel to the collection on the ParentViewModel object.

I have read a lot about relay commands, routed commands, relativesource bindings, the dependancy injection pattern and so forth, but could someone tell me please the ‘proper’ (in an MVVM sense) way to achieve this, and exactly how it is best done. Thank you!

  • 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-10T00:34:46+00:00Added an answer on June 10, 2026 at 12:34 am

    One of the ways I like to handle a situation like this is with Event Aggregating.

    It is an ability added with Unity (if you aren’t already using it)

    Basically you add the Event Aggregator to your Dependancy Injections and then your Parent would subscribe as a listener to the event and your children would publish the event.

    The nice part about this is that the children have no concept of who is listening and the parent just knows it has an event request to handle. For more information you can go HERE!

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

Sidebar

Related Questions

I have a test which looks a bit like this (I'm simplifying a bit
As a means of simplifying development, I'd like to be able to create and
Simplifying I have a text box and a button The button just create an
Well guys, I have three tables here, menu, user and access. For simplifying let's
I have a XML parser which will parse 17 different XML documents (I'm simplifying
I'm using (or trying to) JQuery Validation with WebForms/html. I have, basically (simplifying the
I want to do something like this for simplifying logging operations. Any idea what
For the sake of simplifying my problem, let's say we have three models; user
Simplifying my problem a bit, I have a set of text files with "records"
Simplifying, in my database I have tables: Car (pk=id_car) CarAddon (pk=id_car_fk,id_addon_fk, `FK_car_addon_addon` FOREIGN KEY

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.