Dragging Items from ListViews

You also can drag and drop items in and out of a ListView control. Imagine, for example, that you are using a ListView control to display a list of products and you want users to be able to drag products from the ListView into a shopping cart (see Figure 8.20).

Image

FIGURE 8.20 Dragging items from a ListView to a shopping cart

In that case, you can create the page in Listing 8.21. This page contains a ListView that represents the list of products and a DIV element that represents the shopping cart.

LISTING 8.21 Dragging and Dropping with a ListView (dragDrop\dragDrop.html)

<!DOCTYPE html ...

Get Windows® 8.1 Apps with HTML5 and JavaScript Unleashed now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.