I'm making a chess game with wpf and I have never used wpf before. I've used windows forms, so besides the xaml, it's pretty familiar. Usually when I want to create a mousedown event I look at what I have on window design screen->click the object->go to properties->events->MouseDown event->double click the event->it creates a method that executes when the mouse is pressed on that element. Looks like this...
private void Pawn_1__MouseDown(object sender, MouseButtonEventArgs e)
{
}
But for my chess game in my C# code in the mainwindow constructor I put some initialization code to place a bunch of rectangles all over the screen representing the grid I'd be using for my chess game. How can I create a MouseDown event for these rectangles since they aren't in the designer?