private void PzItmCvs_MouseLeftButtonDown(object sender, MouseButtonEventArgs e) { //Get the canvas associated and the puzzle piece Canvas parent = sender as Canvas; cvDragSource = parent; object data = GetDataFromCanvas(cvDragSource); if (data != null) { PuzzlePiece itemSelected = data as PuzzlePiece; itemSelected.DragFrom = typeof(Canvas); DragDrop.DoDragDrop(cvDragSource, data, DragDropEffects.Move); } } private object GetDataFromCanvas(Canvas cvDragSource) { //first get the index int canvasIndex = int.Parse(cvDragSource.Tag.ToString()); //get the puzzle piece based on the puzzle placement PuzzlePiece item = itemPlacement[canvasIndex]; return item; } puzzle.Edited += new EventHandler(puzzle_Edited); void puzzle_Edited(object sender, EventArgs e) { bool validate = puzzle.Validate(itemPlacement); if (validate) { MessageBox.Show("Congratulations. You solve the puzzle!"); } } public bool Validate(ObservableCollection itemPlacement) { ObservableCollection placement = itemPlacement; foreach (PuzzlePiece item in placement) { if ((placement.IndexOf(item) != item.index) || placement.IndexOf(item) < 0) return false; } return true; } ----------------------------------------------------------\ PuzzleItemDrop puzPiece.NameImage = "";