private void DayAppointmentsStack_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
 {
     if (e.ClickCount > 1)
     {
         var date = new DateTime(MonthView.displayYear, MonthView.displayMonth, Convert.ToInt32(DayNumberLabel.Content));
         var apt = new DayBoxAppointmentControl();
         apt.datetxtBlk.Text = date.ToShortDateString();
         DayAppointmentsStack.Children.Add(apt);
     }
 }
        public void BuildCalendarUI()
        {
            displayDate = DateTime.Now.AddDays(-1 * (DateTime.Now.Day - 1));
            displayMonth = displayDate.Month;
            displayYear = displayDate.Year;
            cultureInfo = new CultureInfo(CultureInfo.CurrentUICulture.LCID);
            sysCal = cultureInfo.Calendar;
            int iDaysInMonth = sysCal.GetDaysInMonth(displayDate.Year, displayDate.Month);
            iOffsetDays = (int)displayDate.DayOfWeek;
            int iWeekCount = 0;
            var weekControl = new DaysOfWeekControl();

            MonthViewGrid.Children.Clear();
            AddRowsToMonthGrid(iDaysInMonth, iOffsetDays);
            switch (displayDate.Month)
            {
                case 1:
                    MonthYearLabel.Content = "January" + " " + displayYear;
                    break;
                case 2:
                    MonthYearLabel.Content = "February" + " " + displayYear;
                    break;
                case 3:
                    MonthYearLabel.Content = "March" + " " + displayYear;
                    break;
                case 4:
                    MonthYearLabel.Content = "April" + " " + displayYear;
                    break;
                case 5:
                    MonthYearLabel.Content = "May" + " " + displayYear;
                    break;
                case 6:
                    MonthYearLabel.Content = "June" + " " + displayYear;
                    break;
                case 7:
                    MonthYearLabel.Content = "July" + " " + displayYear;
                    break;
                case 8:
                    MonthYearLabel.Content = "August" + " " + displayYear;
                    break;
                case 9:
                    MonthYearLabel.Content = "September" + " " + displayYear;
                    break;
                case 10:
                    MonthYearLabel.Content = "October" + " " + displayYear;
                    break;
                case 11:
                    MonthYearLabel.Content = "November" + " " + displayYear;
                    break;
                case 12:
                    MonthYearLabel.Content = "December" + " " + displayYear;
                    break;
            }


            for (int i = 1; i <= iDaysInMonth; i++)
            {
                if ((i != 1) && ((i + iOffsetDays - 1) % 7 == 0))
                {
                    //Add existing weekrow to month Grid
                    Grid.SetRow(weekControl, iWeekCount);
                    MonthViewGrid.Children.Add(weekControl);
                    //Add new Week Row Control
                    weekControl = new DaysOfWeekControl();
                    iWeekCount += 1;
                }
                //load each weekrow with a DayBoxControl whose label is set to day number
                var dayBox = new DayBoxControl();
                dayBox.DayNumberLabel.Content = i.ToString();
                dayBox.Tag = i;
                //Customize DayBox for today
                if (new DateTime(displayYear, displayMonth, i) == DateTime.Today)
                {
                    dayBox.DayNumberLabel.Background = dayBox.TryFindResource("OrangeGradientBrush") as Brush;
                }
             
                DateTime iday = new DateTime(displayYear,displayMonth,i);

                List<ECCAppointment> aptList = StudioRepository.GetAppointmentDayFromRepository(iday).ToList();
                if(aptList.Count > 0)
                {
                    foreach (var item in aptList)
                    {
                        DayBoxAppointmentControl apt = new DayBoxAppointmentControl();
                        apt.DisplayText.Text = item.AppointmentName;
                        apt.datetxtBlk.Text = iday.ToString();
                        dayBox.DayAppointmentsStack.Children.Add(apt);
                    }
                }

                Grid.SetColumn(dayBox, (i - (iWeekCount * 7) + iOffsetDays));
                weekControl.WeekRowGrid.Children.Add(dayBox);
            }
            Grid.SetRow(weekControl, iWeekCount);
            MonthViewGrid.Children.Add(weekControl);
        }