private void RenderBoard(Board board)
        {
            foreach (var positionKey in _squares.Keys)
            {
                var position = new SquareIdentifier(positionKey);
                var square = board[position];

                var gridView = _squares[positionKey];
                var element = gridView.Items.FirstOrDefault() as PieceElement;

                if (element != null)
                {
                    if (square.IsOccupied())
                    {
                        if (element.PieceType != square.Piece.GetType()
                            || element.Color != square.Piece.Color)
                        {
                            gridView.Items.Clear();
                            var pieceElement = new PieceElement(square.Piece);
                            gridView.Items.Add(pieceElement);
                        }
                    }
                    else
                    {
                        gridView.Items.Clear();
                    }
                }
                else if (square.IsOccupied())
                {
                    var pieceElement = new PieceElement(square.Piece);
                    gridView.Items.Add(pieceElement);
                }
            }
        }
 private void OnDragItemsStarting(object sender, DragItemsStartingEventArgs e)
 {
     _draggedFrom = sender as GridView;
     _draggedPiece = e.Items.OfType<PieceElement>().First();
 }