How can buttons withing a ListView itemTemplate perform other actions


  • I want to put one or two of the most common secondary actions within the template for my items in a ListView.  Think music player. Clicking the name plays the track immediately but I also want an "Add to playlist" button on each row.

    When I add a button inside my template, even if I add a handler to that button, the onItemInvoked function for the ListView always gets called and my button's handler never gets called.  This would be fine if I could identify from the onItemInvoked CustomEvent what element had been clicked, however the target and sourceElement are always the outer div of the template and never the actual thing that was clicked.

    Does anyone have some suggestions on how I can go about making this work?  I've seen the samples for selecting an element and presenting the additional options in an appbar but for something as commonly used as "Add to playlist" that's just going to be a poor user experience.

    Tuesday, September 4, 2012 6:42 PM


All replies