c# - How to reach button objects which were created in ItemsControl -


i made buttons in uwp this:

        <itemscontrol x:name="tstack" grid.row="1">         <itemscontrol.itemspanel>             <itemspaneltemplate x:name="ipt">                 <stackpanel x:name="tstack1" orientation="horizontal"/>             </itemspaneltemplate>         </itemscontrol.itemspanel>         <itemscontrol.itemtemplate>             <datatemplate>                 <button height="64" width="64"  tooltipservice.tooltip="{binding name}" click="button_click" tag="{binding appuri}" background="{binding color}"  >                     <stackpanel>                          <image source="{binding iconuri}"></image>                     </stackpanel>                 </button>             </datatemplate>         </itemscontrol.itemtemplate>     </itemscontrol> 

and now, after click each of them want set background of clicked 1 kind of color , set color of background of rest transparent. ideas?

you keep track of active button saving variable. bind of buttons same click-function. when button clicked reset active button's background, change variable clicked button , set background desired color.

button activebutton;  void button_click(object sender, routedeventargs e) {     activebutton.background = null;     activebutton = (button)sender;     activebutton.background = brushes.blue; } 

Comments

Popular posts from this blog

java - Static nested class instance -

c# - Bluetooth LE CanUpdate Characteristic property -

JavaScript - Replace variable from string in all occurrences -