void OnItemClick(object sender, RoutedEventArgs e)
 {
     if (this.chkMoveItemToFrontOnClick.IsChecked ?? false)
     {
         // Move the item that was clicked to the front of the Panel3D scene.
         var elem         = e.Source as FrameworkElement;
         int childIndex   = this.listBox.Items.IndexOf(elem.DataContext);
         int visibleIndex = _panel3D.GetVisibleIndexFromChildIndex(childIndex);
         if (0 < visibleIndex && !_panel3D.IsMovingItems)
         {
             _panel3D.MoveItems(visibleIndex, true);
         }
     }
     else
     {
         MessageBox.Show("You clicked on " + (e.Source as Button).DataContext);
     }
 }
        void Open_Executed(object sender, ExecutedRoutedEventArgs e)
        {
            // The ApplicationCommands.Open command is used for a variety of purposes here.
            // It's a dirty hack, but who cares...this is just a demo.

            var elem         = e.OriginalSource as FrameworkElement;
            int childIndex   = this.listBox.Items.IndexOf(elem.DataContext);
            int visibleIndex = _panel3D.GetVisibleIndexFromChildIndex(childIndex);

            if (0 < visibleIndex)
            {
                // The user clicked on an item that was not in the front of the scene,
                // so tell the Panel3D to animate it to the front.
                if (!_panel3D.IsMovingItems)
                {
                    this.MoveItems(visibleIndex, true);
                }
            }
            else
            {
                XmlAttribute attr = e.Parameter as XmlAttribute;
                if (attr != null)
                {
                    // The user clicked on the button that opens up a blog.
                    string url = attr.Value;
                    if (!String.IsNullOrEmpty(url))
                    {
                        Process.Start(url);
                    }
                }
                else
                {
                    // The user clicked on a blogger's image, so rotate the item.
                    ContentControl3D.RotateCommand.Execute(null, elem);
                }
            }
        }