xaml - Get the listview selected index? -
i creating uwp project. in using listview display content. dynamically adding content listview , done it. have issue when selecting content selectedindex value in -1.
<listview name="mylistview" isitemclickenabled="false" selectionmode="single" selectionchanged="mylistview_selectionchanged_1"> <listview.itemtemplate> <datatemplate> <listviewitem height="80" width="290" tapped="listviewitem_tapped" margin="-10,0,-10,0"> <stackpanel orientation="horizontal" margin="-10,0,-24,0" horizontalalignment="right" width="288" > <border background="#e94f08" height="75" margin="0,0,0,0" width="288" cornerradius="50" > <stackpanel orientation="horizontal"> <ellipse height="68" margin="5,0,0,0" width="70" horizontalalignment="left" > <ellipse.fill> <imagebrush imagesource="/assets/4.jpg"/> </ellipse.fill> </ellipse> <textblock margin="10,0,0,0" verticalalignment="center" horizontalalignment="center" text="{binding name }" foreground="black" fontsize="20"> </textblock> </stackpanel> </border> </stackpanel> </listviewitem> </datatemplate> </listview.itemtemplate> </listview>
you can this,
xaml
<listview x:name="listviewname" isitemclickenabled="true" selectionmode="single" selectionchanged="listview_selectionchanged"> </listview>
c#
private void listview_selectionchanged(object sender, selectionchangedeventargs e) { int index = listviewname.selectedindex; }
hope helps :)
Comments
Post a Comment