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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T01:03:05+00:00 2026-05-17T01:03:05+00:00

I have a shell which looks like toolbar and defines my main region (a

  • 0

I have a shell which looks like toolbar and defines my main region (a wrap panel). What I need to do is be able to add widgets to the shell and when a widget is clicked, a new window (view) is opened. Below is what I have so far:

I created a module class which adds a view to the main region:

public class MyModule : IModule
{
  protected IUnityContainer Container { get; private set; }

  public MyModule(IUnityContainer container)
  {
    Container = container.CreateChildContainer();
  }

  public void Initialize()
  {
    var regionManager = Container.Resolve<IRegionManager>();
    MyModuleView myModuleView = new MyModuleView();
    regionManager.Regions["MainRegion"].Add(myModuleView);
  }
}

Here is the content of MyModuleView:

  <Grid>
    <Grid.DataContext>
      <vm:MyModuleVM/>
    </Grid.DataContext>
    <Button Content="My Module" Foreground="White" FontWeight="Bold" Command="{Binding Path=LaunchCommand}">
    </Button>
  </Grid>

The view model, MyModuleVM:

  class MyModuleVM : ObservableObject
  {
    protected IUnityContainer Container { get; private set; }

    public MyModuleVM()
    {
    }

    RelayCommand _launchCommand;
    public ICommand LaunchCommand
    {
      get
      {
        if (_launchCommand == null)
        {
          _launchCommand = new RelayCommand(() => this.LaunchTestView(),
              () => this.CanLaunchTestView());
        }
        return _launchCommand;
      }
    }

    private void LaunchTestView()
    {
      TestView view = new TestView();
      view.Title = "Test View";
      var regionManager = Container.Resolve<IRegionManager>();
      regionManager.Regions["MyWindowRegion"].Add(view);
    }

    private bool CanLaunchTestView()
    {
        return true;
    }
  }

So my plan was as follows:

  • Create the class that implements
    IModule (MyModule) and have it load a
    view (MyModuleView) into the shell
    when initialized

  • Create a view model for the module
    (MyModuleVM) and set it as the
    DataContext of the view displayed in
    the shell

  • MyModuleVM contains a command that a
    button in MyModuleView binds to.
    When the button is clicked the
    command is triggered

  • Now, here is where I am stuck. Using
    a WindowRegionAdapter (an adapter
    that helps to create views in
    separate windows) I wanted to create
    and display a new view. As seen in
    MyModuleVM, LaunchTestView needs
    access to the container in order to
    add the view to a region. How am I
    supposed to get to the container?

Besides my specific question about accessing the container, how is my overall strategy of adding “widgets” to a toolbar shell and launching
views when they are clicked? Am I comlpetely off track here when it comes to MVVM with Prism?

Thanks guys.

  • 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-17T01:03:05+00:00Added an answer on May 17, 2026 at 1:03 am

    You can get the container injected through constructor or property injection. To do that, the ViewModel instance must be resolved by the container, or the BuildUp method should be called after it has been instantiated.

    I hope this helps.

    Thanks,
    Damian

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

Sidebar

Related Questions

I have a simple shell script which looks like this: R --vanilla<myMRjob.R hadoop fs
I have an AWK script which looks like #!/usr/bin/gawk -f BEGIN { print myVar;
I have a save function within my Python program which looks like this: def
In a shell script I have a variable $PATH which could look like this:
I have a document which looks something like: { _id : ObjectId(4e84f78b26d2046d5d00b5b2), parent_id :
I have a shell variable which points to the directory where all my configuration
I have a shell script which outputs all of the .js and .html files
Hi I have a shell script which should run based on the return of
I am talking about windows shell extensions. I have a shell extension which could
I have a shell script in which I have to execute two queries (on

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.