You can add _target.Click += _target_Click;
in your mainArea_PreviewMouseLeftButtonDown event and add below code for _target_Click
private void _target_Click(object sender, RoutedEventArgs e)
{
Button btn = sender as Button;
MessageBox.Show(btn.Name);
}
If the response is helpful, please click "Accept Answer" and upvote it.
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.