c# - How to i add an Item Click event to an items control -


i having problems generating click event items inside items control. new xaml nad wpf. can experts me out. below code have come having no clue on how add click event generated items. appreciate responses. thank reading

<itemscontrol itemssource="{binding text, source={staticresource textcontainer}}">             <!--text object bein made public texttodisplay. there can many objects released ratger 1 in case-->             <itemscontrol.itemspanel>                 <itemspaneltemplate>                     <wrappanel itemwidth="100"                                itemheight="100" />                 </itemspaneltemplate>             </itemscontrol.itemspanel>             <itemscontrol.itemtemplate>                 <datatemplate datatype="{x:type sys:string}">                     <border cornerradius="100"                             background="blueviolet">                         <button margin="20"                                    content="{binding}"                                    horizontalcontentalignment="center" />                     </border>                 </datatemplate>             </itemscontrol.itemtemplate>         </itemscontrol> 

probably easiest thing can create own user control... make custom button , add click event control everytime listbox add control have click_event built in.

    private void button_click_1(object sender, routedeventargs e)     {         // add code here.     } 

then listbox that...

    private void additemsbutton_click(object sender, routedeventargs e)     {          listboxtest.items.add(new usercontrol1());     } 

this adds usercontrol button listbox everytime click on button titled "add items"


Comments

Popular posts from this blog

android - MPAndroidChart - How to add Annotations or images to the chart -

javascript - Add class to another page attribute using URL id - Jquery -

firefox - Where is 'webgl.osmesalib' parameter? -