I have multiple custom controls, and I noticed that all of them share the same event (custom) example : OnMoved etc
What I'm doing now is, copy & paste the same code from controls to controls.
So, are there anyway for me to write custom events that can be shared throughout all my controls in C# WPF?
An example of an event that I use for all my controls :
Point lastPosition = new Point();
Point currentPosition = new Point();
public static void OnMoved(object sender, EventArgs e)
{
currentPosition.X = Canvas.GetLeft(explorer);
currentPosition.Y = Canvas.GetTop(explorer);
// didn't moved
if (currentPosition.X == lastPosition.X || currentPosition.Y == lastPosition.Y)
{
return;
}
lastPosition.X = Canvas.GetLeft(explorer);
lastPosition.Y = Canvas.GetTop(explorer);
}