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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T20:53:32+00:00 2026-05-20T20:53:32+00:00

My application can have multiple designer windows. Each window constitutes of several user controls

  • 0

My application can have multiple designer windows. Each window constitutes of several user controls which communicates dynamically with the help of RelayCommands. I created the following class as the backbone of the commanding infrastructure.

public static class Commands
{
    public static readonly RoutedCommand EntityEditRequest = new RoutedCommand();
    public static  RelayCommand EntityEditorChangeRequest;
    public static RelayCommand XMLUpdateRequest;
    public static RelayCommand SaveRequest;   
}

Each viewmodel for the user controls will do something like this in the constructor

 public XMLEditorViewModel()
 {
        Commands.Commands.SaveRequest = new RelayCommand(Save_Executed);
        Commands.Commands.XMLUpdateRequest = new RelayCommand(UpdateXML); 
 }

However, I completely missed the point that the application can have multiple windows. When each window is opened the static Commands are set for that particular window.

Example:

Window A is opened-the constructors for the usercontrols set the RelayCommands and all is well.

Window B opened-the constructors for the usercontrols set the RelayCommands. Window A’s command binding is lost!

So when I change the tab to Window A(the windows are tabbed) no commands are working.

I need some idea so that when I change the tab the active window always sets the commands. I can try to put the commanding in tab_selection_changed event, but somehow it is looking bad to me. Is there a proper way to do this? Any help is much appreciated.

Edit:

The question proved a bit confusing among the readers. I am not trying to make multiple subscribers for a command. At any given point only one window is active. This window consists several user controls-some of them loaded dynamically with the help of commands; but each command is handled by a single view model class-so no multi subscribers. My problem is the application can load multiple windows in tabs-only one window is active at any given point-but the user can do to a different tab and make another window active. As the view model constructor assigns the static RelayCommands, when each new window is loaded the static command is set to a new binding.

Window A opened-window A view model constructor sets the static command bind to its object command handler. Window A is active. Commanding is fine.

Window B loaded-window B view model constructor sets the static command bind to its object command handler. Window B is active. Commanding is fine.

Now, User select the Window A tab to set the Window A as active. Commanding wont work. Of course it wont as the Command is bind to Window B command handler.

Theoretically static commands can handle the scenario as at any given point there will be only one active window. But how??

  • 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-20T20:53:33+00:00Added an answer on May 20, 2026 at 8:53 pm

    The global command should be a CompositeCommand or similar approach (CompositeCommand is from Prism). This will allow multiple children to register with the command.

      public static CompositeCommand SaveCommand = new CompositeCommand();
    

    The command can then be accessed across the ViewModels or where applicable like so…

      SaveCommand = new DelegateCommand<object>(Save, CanExecuteSave);
      GlobalCommands.SaveCommand.RegisterCommand(SaveCommand);
    

    You can then leverage the IActiveAware interface to define which Window is the active Window and act on the command accordingly.

    There is also an MSDN posting on creating globally available commands. Don’t forget to unregister the command to avoid a memory leak.

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

Sidebar

Related Questions

I have a Windows Forms (.NET) application that can have multiple documents open simultaneously.
I have a web application with users and their documents. Each user can have
I have a custom class loader so that a desktop application can dynamically start
We have a hosted application that manages pages of content. Each page can have
I have a C++ Windows application that can be extended by writing C++ plugins,
Can we have multiple HTML files in Phonegap application?
I have multiple business objects in my application (C#, Winforms, WinXP). When the user
I have an application which will be used by multiple companies.So my views/pages are
Is it possible to have multiple folders where I can place applications to be
I have a console application written in Delphi. I saw that I can have

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.