First of all, why don't you add the button to your user control instead of on the form?
if this is really your business case:
Add controls to form[
^]
then you'll need to attach an event handler to it.
I suggest you make sure the Button has a unique name or id in it's properties and let all buttons call the same handler. In that handler you check who called it and act accordingly.
Example[
^]
in this example you could modify the code similar to this:
public partial class RoutedEventAddRemoveHandler {
void MakeButton(object sender, RoutedEventArgs e)
{
Button b1 = new Button();
Button b2 = new Button();
b1.Content = "New Button 1";
b2.Content = "New Button 2";
b1.Click += new RoutedEventHandler(OnbClick);
b2.Click += new RoutedEventHandler(OnbClick);
text1.Text = "Now click the second button...";
}
void OnbClick(object sender, RoutedEventArgs e)
{
if( ((Button)sender).Content == "New Button 1"){
text1.Text = "New Button (b1) Was Clicked!!";
}
else{
text1.Text = "New Button (b2) Was Clicked!!";
}
}
perhaps "Content" is not the best property to set uniquely, so find another like Name or Tag (depending on what is available)
hope this helps.