c# - Windows Phone 8.1 gridview -
how can create stackpanel in gridview various elements in stackpanel responding different click event?
the stackpanel contain 2 appbarbutton , each appbarbutton has textblock increments based on number of clicks...
<gridview itemssource={binding}> <gridview.itemtemplate> <datatemplate> <stackpanel orientation="horizontal"> <stackpanel orientation="vertical"> <stackpanel orientation="horizontal"> <appbarbutton icon="like" name="like" iscompact="true" click="like_click"/> <textblock name="numoflike" text="{binding no_positive_likes}"/> </stackpanel> <stackpanel orientation="horizontal"> <appbarbutton icon="dislike" name="dislike" iscompact="true" click="dislike_click"/> <textblock name="numofdislike" text="{binding no_negative_likes}"/> </stackpanel> </stackpanel> <stackpanel orientation="vertical" tapped="loadquestionanswer_click"> <textblock name="question" text="what name" fontsize="30"/> <textblock text="2013-12-10"/> </stackpanel> </stackpanel> </datatemplate> </gridview.itemtemplate> </gridview>
i have handled same scenario using behaviorssdk.this sdk makes life easy adding ability call function event. add reference in project behaviorssdk , add method item data class each event. here example:
observablecollection<itemmodel> items; public class itemmodel { public bool no_positive_likes ... public bool no_negative_likes ... public void likebuttonpressed() { ... } public void dislikebuttonpressed() { ... } }
then in xamll:
xmlns:i="using:microsoft.xaml.interactivity" xmlns:core="using:microsoft.xaml.interactions.core" ... <gridview itemssource={binding}> <gridview.itemtemplate> <datatemplate> <stackpanel orientation="horizontal"> <stackpanel orientation="vertical"> <stackpanel orientation="horizontal"> <appbarbutton icon="like" name="like" iscompact="true"> <i:interaction.behaviors> <core:eventtriggerbehavior eventname="click"> <core:callmethodaction targetobject="{binding mode=oneway}" methodname="likebuttonpressed"/> </core:eventtriggerbehavior> </i:interaction.behaviors> </appbarbutton>
Comments
Post a Comment