private void OnSolutionTimerTick()

in Games/Maze/GamePage.xaml.cs [246:303]


        private void OnSolutionTimerTick(object sender, object e)
        {
            var brush = SolveBrush;
            var cell = MazeGrid.Children.Cast<FrameworkElement>().First(b => Grid.GetRow(b) == _curRow && Grid.GetColumn(b) == _curCol) as Border;
            cell.Background = brush;

            var currentContent = _curButton.Content;

            if (_solutionCurIndex >= _solution.Count())
            {
                _solutionTimer.Stop();
                _isMazeSolved = true;

                //_curButton.Content = _mazeComplete;
                HideMazeRunnerVisual(0);
                return;
            }
            else
            {
                _curButton.Content = null;
            }            

            var pos = _solution.ElementAt(_solutionCurIndex);
           
            //If cell has visualchild remove it            
            ElementCompositionPreview.SetElementChildVisual(cell, null);
           

            if (pos == Direction.Left)
            {
                _curCol--;
                AnimateMazeRunnerVisualToCell(_curCol, _curRow, TravelSpeed.Run, 0);
            }
            if (pos == Direction.Right)
            {
                _curCol++;
                AnimateMazeRunnerVisualToCell(_curCol, _curRow, TravelSpeed.Run, 0);
            }
            if (pos == Direction.Up)
            {
                _curRow--;
                AnimateMazeRunnerVisualToCell(_curCol, _curRow, TravelSpeed.Run, 0);
            }
            if (pos == Direction.Down)
            {
                _curRow++;
                AnimateMazeRunnerVisualToCell(_curCol, _curRow, TravelSpeed.Run, 0);
            }
            _solutionCurIndex++;

            Border curBorder = MazeGrid.Children.Cast<FrameworkElement>().First(b => Grid.GetRow(b) == _curRow && Grid.GetColumn(b) == _curCol) as Border;
            _curButton = curBorder.Child as Button;

            if (_solutionCurIndex < _solution.Count())
            {
                _curButton.Content = currentContent;
            }
        }