public void GameButton_Click(object sender, RoutedEventArgs e)
        {
            if (true == wingame)
            {
                MessageBox.Show("You have to restart again to play game");
                return;
            }

            GameButton      btn      = sender as GameButton;
            GameButtonState btnState = new GameButtonState(btn.Id, btn);
            // int digit = Convert.ToInt32(btn.Content.ToString());
            int row   = ((int)btn.GetValue(Grid.RowProperty));
            int col   = ((int)btn.GetValue(Grid.ColumnProperty));
            int digit = row * nRows + col;

            btn.Position    = digit;
            btnState.Oldpos = btn.Position;
            //record into undo/redo stack before moving.
            btn.Move();
            btnState.Newpos = btn.Position;
            gameUndoStack.Push(btn);
            gameReplayList.Add(btnState);

            Title = gameUndoStack.Count.ToString();
        }//end GameButton_Click
 void undoItem_Click(object sender, RoutedEventArgs e)
 {
     try
     {
         //fromgamestatelist remove lastitem
         GameButton btn = gameUndoStack.Pop();
         btn.Move();
         Title = gameUndoStack.Count.ToString();
     }
     catch (Exception ex)
     {
         MessageBox.Show("Game Board Is in Original State!, No further undo possible");
     }
 }