locked
change the background button color of a dynamic button

    Question

  • Dear team,

                     i have created around 50 buttons dynamically. by clicking each button it will display different questions and i have one more button called "Mark the Question" when i press the "Mark the Question" button i have to change the Background color of  the question button which i have created dynamically.

    i have to code for changing the background color. i am not able change to dynamic button

                btn.Background = new SolidColorBrush(Colors.Red);

    Thanks 

    Tuesday, October 14, 2014 2:33 AM

Answers

  • i got the answer

    GridQuestionButton is grid

     var but= GridQuestionButton.FindName(slno[i].ToString());
    
                Button btn = (Button)but;
                btn.Background = new SolidColorBrush(Colors.Red);

    • Marked as answer by mann madhan1 Tuesday, October 14, 2014 2:51 AM
    Tuesday, October 14, 2014 2:51 AM

All replies

  • i got the answer

    GridQuestionButton is grid

     var but= GridQuestionButton.FindName(slno[i].ToString());
    
                Button btn = (Button)but;
                btn.Background = new SolidColorBrush(Colors.Red);

    • Marked as answer by mann madhan1 Tuesday, October 14, 2014 2:51 AM
    Tuesday, October 14, 2014 2:51 AM
  • Good to know :)

    FindName method could be a good thing for you.

    --James


    <THE CONTENT IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, WHETHER EXPRESS OR IMPLIED>
    Thanks
    MSDN Community Support

    Please remember to "Mark as Answer" the responses that resolved your issue. It is a common way to recognize those who have helped you, and makes it easier for other visitors to find the resolution later.

    Wednesday, October 15, 2014 1:15 AM
    Moderator