/// <summary>
        /// Builds the grid.
        /// </summary>
        public void BuildGrid()
        {
            //DateTime dt = DateTime.Now;
            var previousMonth       = _currentMonth.AddMonths(-1);
            var nextMonth           = _currentMonth.AddMonths(1);
            var daysInPreviousMonth = DateTime.DaysInMonth(previousMonth.Year, previousMonth.Month);
            var daysInMonth         = DateTime.DaysInMonth(_currentMonth.Year, _currentMonth.Month);
            var firstDayOfWeek      = (int)CultureInfo.CurrentCulture.DateTimeFormat.FirstDayOfWeek;

            WeekdayOfFirst = (int)_currentMonth.DayOfWeek;
            //var lead = daysInPreviousMonth  - ((weekdayOfFirst+firstDayOfWeek) - 1);

            var boxWidth  = _calendarMonthView.BoxWidth;
            var boxHeight = _calendarMonthView.BoxHeight;

            var numberOfLastMonthDays = (WeekdayOfFirst - firstDayOfWeek);

            if (numberOfLastMonthDays < 0)
            {
                numberOfLastMonthDays = 7 - (WeekdayOfFirst + firstDayOfWeek);
            }
            var lead = daysInPreviousMonth - numberOfLastMonthDays + 1;

            // build last month's days
            for (var i = 1; i <= numberOfLastMonthDays; i++)
            {
                var viewDay = new DateTime(previousMonth.Year, previousMonth.Month, lead);
                var dayView = new CalendarDayView(_calendarMonthView)
                {
                    Frame =
                        new CGRect((i - 1) * boxWidth, 0, boxWidth, boxHeight),
                    Date = viewDay,
                    //Disabling previous month dates to show
                    Text = "",
                    // Text = lead.ToString(),
                    //For the dates of previous month
                    TextDot = ""
                };
                UpdateDayView(dayView);
                AddSubview(dayView);
                DayTiles.Add(dayView);
                lead++;
            }

            var position = WeekdayOfFirst - firstDayOfWeek + 1;

            if (position == 0)
            {
                position = 7;
            }
            var line = 0;

            // current month
            for (int i = 1; i <= daysInMonth; i++)
            {
                var viewDay = new DateTime(_currentMonth.Year, _currentMonth.Month, i);
                var dayView = new CalendarDayView(_calendarMonthView)
                {
                    Frame =
                        new CGRect(
                            (position - 1) * boxWidth,
                            line * boxHeight,
                            boxWidth,
                            boxHeight),
                    Today = (CurrentDate.Date == viewDay.Date),
                    Text  = i.ToString(),
                    //For current month dates
                    TextDot  = ".",
                    Active   = true,
                    Tag      = i,
                    Selected =
                        (viewDay.Date == _calendarMonthView.CurrentSelectedDate.Date),
                    Date = viewDay
                };

                UpdateDayView(dayView);

                if (dayView.Selected)
                {
                    SelectedDayView = dayView;
                }

                AddSubview(dayView);
                DayTiles.Add(dayView);

                position++;
                if (position > 7)
                {
                    position = 1;
                    line++;
                }
            }

            //next month
            int dayCounter = 1;

            if (position != 1)
            {
                for (int i = position; i < 8; i++)
                {
                    var viewDay = new DateTime(nextMonth.Year, nextMonth.Month, dayCounter);
                    var dayView = new CalendarDayView(_calendarMonthView)
                    {
                        Frame = new CGRect((i - 1) * boxWidth, line * boxHeight, boxWidth, boxHeight),
                        //Disabling Next month dates to show
                        Text = "",
                        //Text = dayCounter.ToString(),
                        //For the date of next month
                        TextDot = "",
                    };
                    dayView.Date = viewDay;
                    UpdateDayView(dayView);

                    AddSubview(dayView);
                    DayTiles.Add(dayView);
                    dayCounter++;
                }
            }

            //Why to add unnecesarry unclickable dates of next month?
            //          while (line < 5)
            //          {
            //              line++;
            //              for (int i = 1; i < 8; i++)
            //              {
            //                  var viewDay = new DateTime (_currentMonth.Year, _currentMonth.Month, i);
            //                  var dayView = new CalendarDayView (_calendarMonthView)
            //                  {
            //                      Frame = new RectangleF((i - 1) * boxWidth -1, line * boxHeight, boxWidth, boxHeight),
            //                      Text = dayCounter.ToString(),
            //                  };
            //                  dayView.Date = viewDay;
            //                  updateDayView (dayView);
            //
            //                  AddSubview (dayView);
            //                  _dayTiles.Add (dayView);
            //                  dayCounter++;
            //              }
            //          }

            Frame = new CGRect(Frame.Location, new CGSize(Frame.Width, (line + 1) * boxHeight));

            Lines = (position == 1 ? line - 1 : line);

            if (SelectedDayView != null)
            {
                BringSubviewToFront(SelectedDayView);
            }
            //Console.WriteLine("Building the grid took {0} msecs",(DateTime.Now-dt).TotalMilliseconds);
        }
 /// <summary>
 /// Updates the day view.
 /// </summary>
 /// <param name="dayView">The day view.</param>
 public void UpdateDayView(CalendarDayView dayView)
 {
     dayView.Marked      = _calendarMonthView.IsDayMarkedDelegate != null && _calendarMonthView.IsDayMarkedDelegate(dayView.Date);
     dayView.Available   = _calendarMonthView.IsDateAvailable == null || _calendarMonthView.IsDateAvailable(dayView.Date);
     dayView.Highlighted = _calendarMonthView.HighlightedDaysOfWeek[(int)dayView.Date.DayOfWeek];
 }