开发者

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);

}


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜