locked
VS 2012 C# perform Click Event from a function for a specific button at a time ? RRS feed

  • Question

  • I am creating a windows store application for which I have to program computer to perform a click on different button after the user has clicked a button. I have Implemented the logic for computer click. But the code "b1.Click += btnClick;" doesn't help me to perform a click event on the "b1" button. Please tell how to do so. And please mention the namespace too if any extra to be used.
    Wednesday, January 8, 2014 3:09 AM

Answers

  • Instead of performing a Click event on the second button pull the code that responds to the click into a separate function which you can call from both buttons.

    b1_Click_handler(object s, RoutedEventArgs e)
    {
       doButton1Stuff();
       doButton2Stuff();
    }
    
    b2_Click_handler(object s, RoutedEventArgs e)
    {
       doButton2Stuff();
    }
    
    
    

    Wednesday, January 8, 2014 3:59 AM
    Moderator