This code sample, uses two layers. When you click on a shape in a layer, it swaps the zIndex of the layers such that the layer the shape is in, is on top. Additional information zIndexing in Bing Maps V8 can be found here.