how to get the tag value of image in below lines of code in silverlight? -
i binding items follows:
<scrollviewer> <itemscontrol x:name="userlist"> <itemscontrol.itemspanel> <itemspaneltemplate> <stackpanel orientation="horizontal" /> </itemspaneltemplate> </itemscontrol.itemspanel> <itemscontrol.itemtemplate> <datatemplate> <image source="{binding imageurl}" tag="{binding path=id}" width="164" height="150" margin="4" stretch="fill"></image> </datatemplate> </itemscontrol.itemtemplate> </itemscontrol> </scrollviewer>
code.cs:
list.add(new stackimages { id = "1", imageurl = new uri(this.baseuri, @"assets/acservice.png") }); list.add(new stackimages { id = "2", imageurl = new uri(this.baseuri, @"assets/brakes.png") }); list.add(new stackimages { id = "3", imageurl = new uri(this.baseuri, @"assets/carwash.png") }); list.add(new stackimages { id = "4", imageurl = new uri(this.baseuri, @"assets/oilchange.png") }); list.add(new stackimages { id = "5", imageurl = new uri(this.baseuri, @"assets/transmission.png") }); userlist.itemssource= list;
please tell me how particulat image tag value when tap on it?
add tap
handler image.
... <datatemplate> <image source="{binding imageurl}" tap="mytaphandler" tag="{binding path=id}" width="164" height="150" margin="4" stretch="fill"></image> </datatemplate>
in code behind:
private void mytaphandler(object sender, eventargs e) { image sourceimage = sender image; string id = sourceimage.tag string; //do stuff id }
Comments
Post a Comment