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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T07:39:01+00:00 2026-06-12T07:39:01+00:00

i need to invoke multiple instances of a command for this example i’ll take

  • 0

i need to invoke multiple instances of a command

for this example i’ll take 2 controls ‘A’ and ‘B’

‘A’ would be the Invoker and ‘B’ the invokie and there are multiple instances of ‘B’

the Controls :

 public class A : Control 
 {
     public A()
     {}

     public ICommand OnACommand   
     {
        get { return (ICommand)GetValue(OnAProperty); }
        set { SetValue(OnACommandProperty, value); }
     }

    public static readonly DependencyProperty OnACommandProperty =
        DependencyProperty.Register("OnACommand", typeof(ICommand), typeof(A), new UIPropertyMetadata(null));

     public bool Something   
     {
        get { return (bool)GetValue(SomethingProperty); }
        set { SetValue(SomethingProperty, value); }
     }

    public static readonly DependencyProperty SomethingProperty=
        DependencyProperty.Register("Something", typeof(bool), typeof(A), new UIPropertyMetadata(false,OnSometingPropertyChanged));

    private static void  OnSometingPropertyChanged(...)
    {
        ... 
        OnACommand.Execute(this.Value);
    }                  
 }


 public class B : Control 
 {
     public B(){ }

     public ICommand OnBCommand   
     {
        get { return (ICommand)GetValue(OnBCommandProperty); }
        set { SetValue(OnBCommandProperty, value); }
     }

    public static readonly DependencyProperty OnBCommandProperty =
        DependencyProperty.Register("OnBCommand", typeof(ICommand), typeof(B), new UIPropertyMetadata(null));              
 }

the Binding :

   <local:B  x:Name="B1" OnBCommand="{Binding ElementName=A1 , Path=OnACommand />
   <local:B  x:Name="B2" OnBCommand="{Binding ElementName=A1 , Path=OnACommand />   
   <local:A  x:Name="A1"  />   

what i need is for all the B Commands Bound to that A command to Execute when Executing OnACommand.

the only approach which i would think to work is if i implemented the Command inside B and bound it OneWayTosource , but than only the last one the Bind to A would be the B which would get Executed .

  public B()
  {
       OnBCommand = new RelayCommand<int> 
                    (
                        value => { this.Value = value ....}
                    );
  }

   <local:B  x:Name="B1" 
             OnBCommand="{Binding ElementName=A1,Path=OnACommand,Mode=OneWayToSource />
   <local:B  x:Name="B2" 
             OnBCommand="{Binding ElementName=A1,Path=OnACommand,Mode=OneWayToSource />   
   <local:A  x:Name="A1"  />   

if i bound it any other way like OneWay i need to implement the Command in A and B has no idea
that it was even executed, unless it’s possible to some how acknowledge the execution from a delegate within B ..

so to summarize i need to execute multiple targets from one source.

in addition i might point out that i solved this using a regular .net event which i declared in ‘A1’
and Subscribed all the B’s to,but since this is WPF written in MVVM i’m looking for the MVVM Style Way of doing this , using Commands .

thanks in advance.

  • 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-12T07:39:02+00:00Added an answer on June 12, 2026 at 7:39 am

    A possible approach to achieve what you are trying to get done is using a composite command.

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

Sidebar

Related Questions

I need to delete multiple rows from my database table. This is my code
I am making an application where I need to invoke requests in multiple view
I need to invoke getoptlong multiple times, but after the first time ARGV is
I need to invoke a method without knowing a priori what will the amount
I need to invoke a call from code how can i do it ?
I need to invoke a server side function when an item is picked in
I need to invoke a mapreduce job from java application. I use ToolRunner.run(new Validation(),
I need to invoke the setter methods of a class using reflection, and the
I need to invoke Selenium from Client Side, so I'm trying to run Selenium
I have a list of callback functions that I need to invoke when an

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.