i have many buttons in universal app end code this:
private void btn1_click(object sender, routedeventargs e) { choix_buttons(sender, e); } private void btn2_click(object sender, routedeventargs e) { choix_buttons(sender, e); } ......... private async void choix_buttons(object sender, routedeventargs e) { button btn = sender button; switch (btn.name) { case "btn1": //do button1's style break; case "btn2": //do button2's style break; } ...all other buttons }
my code applies specific style every selected button, have problem, when click on button2 applies style button2, when click on button1 applies style button1, , on, more button has style applied.
so how can please clear modification have apply each button before access switch case clause? help.
you have few options. 1. can loop through of controls, , if button, apply default style. problematic if have buttons don't want apply to. 2. can hold reference button styled, so:
//your reference styledbutton private button styledbutton; private void btn1_click(object sender, routedeventargs e) { choix_buttons(sender, e); } private void btn2_click(object sender, routedeventargs e) { choix_buttons(sender, e); } private async void choix_buttons(object sender, routedeventargs e) { //here can set styledbutton = default styling button btn = sender button; switch (btn.name) { case "btn1": //do button1's style break; case "btn2": //do button2's style break; } ...all other buttons //and here set styledbutton = button pressed styledbutton = btn; }
Comments
Post a Comment