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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T18:07:53+00:00 2026-05-15T18:07:53+00:00

I have a parent View that is xaml-binded to a ViewModel (the viewmodel is

  • 0

I have a parent View that is xaml-binded to a ViewModel (the viewmodel is declared in the xaml).

This parent view can then display a child View (via NavigationService, aka navigation:Frame).

The parent view never goes out of scope, but I want the new child View to share the parent’s ViewModel.

How can i do this? Because by declaring the same viewmodel in the child View’s xaml would mean the child view gets it’s own viewmodel instance (i.e. it is not the same viewmodel instance as it’s parent view).

Thanks!

  • 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-15T18:07:53+00:00Added an answer on May 15, 2026 at 6:07 pm

    Sounds like a perfect opportunity to either (a) use MEF. Export the view model, then import it in both the parent and child views. By default, they will share the same object. Or (b) create a locator class that keeps track of the view model instances, exposed via a static property, and use that static property to retrieve the view model in the parent and the child:

    public static class Locator 
    {
       private static readonly MyViewModel _instance = new MyViewModel();
    
       public static MyViewModel Instance 
       {
          get { return _instance; }
       }
    }
    
    public partial class MyView
    {
        public MyView()
        {
           InitializeComponent();
           LayoutRoot.DataContext = Locator.Instance;
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a parent view that defines a child view in Xaml. The child
I have parent/child relationship set up via Node Reference. A Child record can have
I have a parent view (table) that passes a detail object to the child
I have a parent-child view model object structure set up and need to update
Suppose I have a parent.cshtml view with a parentModel, and a child.cshtml view with
I have the following (condensed) silverlight xaml for a view / viewmodel: <UserControl x:Class=MyView>
I have parent view that also renders sub-controller action using RenderAction() (that returns a
If I have a parent view controller that displays a modal view with a
So I have a custom ArrayAdapter so I can use the Title/Subtitle view that
Hi hoping someone can help. I have a list view that displays various textviews,editviews

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.