Animor
Animor

Reputation: 83

WPF Rectangle CommandBinding MVVM

I have the following problem I have a lot of rectangles(or a paths) and I want to add a command to every rectangle, that when I click the rectangle an object will be fill with the values of the rectangle(color,name).And from the GUI I want to change the color of the rectangle when I execute the command How can I do that in MVVM?

For example I have an object Ractangle

public Class Rectangle{
        String name;
        String color;

   public String Color{
      get{ return color;}
      set {color=value;}

      OnPropertyChange(color);
}

  public String Name{
      get{ return name;}
      set {name=value;}
      OnPropertyChange(name);

}

Upvotes: 0

Views: 1915

Answers (1)

dain
dain

Reputation: 6689

I think it would be easier if you wrapped your Rectangle into a Button which gives you the readily usable Command property you can bind a command to. To be honest though I'm not 100% sure what you're after, please elaborate your scenario.

Upvotes: 1

Related Questions