hi there is a class

public class Cell : Image { public event MouseButtonEventHandler LeftClick { add { MouseLeftButtonDown += value; } remove { MouseLeftButtonDown -= value; } } static Cell() { DefaultStyleKeyProperty.OverrideMetadata(typeof(Cell), new FrameworkPropertyMetadata(typeof(Cell))); } public event MouseButtonEventHandler RightClick { add { MouseRightButtonDown += value; } remove { MouseRightButtonDown -= value; } } } 

In another class, I created several instances of this class. But I want to process the mouse click in a separate class. How can you go there to transfer these events. I made 2 events

 public event MouseButtonEventHandler LeftClick { add { MouseLeftButtonDown += value; } remove { MouseLeftButtonDown -= value; } } public event MouseButtonEventHandler RightClick { add { MouseRightButtonDown += value; } remove { MouseRightButtonDown -= value; } } 

But that does not work out. How to. As I understand it, delegates should probably be used, but I don’t understand how.

  • myCell.LeftClick += otherObj.Method; - Andrei NOP
  • four
    It is not clear what you need. Events for the Cell class must be defined in the Cell class. But you can subscribe to them anywhere. - VladD
  • Well, I in the class classTwo created 10 pcs Cell. And I want to handle the event of clicking on them in ClassThee. - Sasuke
  • all figured out thanks - Sasuke

0