c# - How can I change the visibility of another object in the same ListBox in Windows Phone? -


an excerpt xaml:

<listbox x:name="list" margin="0,0,0,0" itemssource="{binding items}">      <listbox.itemtemplate>          <datatemplate>            <stackpanel orientation="horizontal" background="lightgray" margin="0,5,0,0" >                 <image name="like" source="/images/like1.png"  tap="like_tap"/>                 <image name="unlike" visibility="collapsed"  source="/images/unlike1.png" tap="unlike_tap"/>                 <image name="comment" source="/images/comment1.png" margin="30,0,0,0"/>           </stackpanel>         </datatemplate>     </listbox.itemtemplate> </listbox>   

now here problem

in c# code:

private void like_tap(object sender, system.windows.input.gestureeventargs e) {        // here i'm unable change visibility of either image. how do this? } 

i behaviour spread unlike button too.

how do this? thanks!

instead of accessing image in code recommend use binding achieve this.

create property of bool type in item class , bind property visibility property of image. need visibility boolean converter.

 <image visibility="{binding path=showlikeimage converter={static resource visibilitytobooleanconverter}}"  source="/images/unlike1.png" tap="unlike_tap"/> 

on tap event have change showlikeimage property , ui automatically update itself.


Comments