private void month_MonthSelected(object sender, MonthSelectArgs e) { Month month = e.Month; if (lastMonth != null) { for (int i = 0; i < Months.Count; i++) { if (lastMonth.SelectedDate.Month == Months[i].SelectedDate.Month) if (lastMonth.SelectedDate.Day == Months[i].SelectedDate.Day) { lastMonth = Months[i]; Months.RemoveAt(i); Months.Insert(i, lastMonth); } } } lastMonth = month; DateTime dateTime = DateTime.Now; try { dateTime = lastMonth.SelectedDate; SelectedDateTime = new DateTime(YearTitle, dateTime.Month, dateTime.Day); } catch (Exception) { SelectedDateTime = DateTime.Now; } finally { UpdateDays(SelectedDateTime); semanticzoomDate.ToggleActiveView(); } this.header.MonthTitle = SelectedDateTime.Month.ToString(); this.header.YearTitle = SelectedDateTime.Year.ToString(); this.MonthTitle = SelectedDateTime.Month; this.YearTitle = SelectedDateTime.Year; }
void CalendarItemMonthButton_Click(object sender, RoutedEventArgs e) { Month month = this.DataContext as Month; month.OnMOnthSelected(); }
private ObservableCollection<Month> CreateMonth(DateTime date) { months.Clear(); int monthIndex = 1; while (monthIndex < 13) { Month month = new Month() { SelectedDate = new DateTime(date.Year, monthIndex, date.AddMonths(monthIndex - 1).Day), DefaultDate = date, CurrentDate = date, Days = days == null ? CreateDay(date) : days }; month.MonthSelected += month_MonthSelected; Months.Add(month); monthIndex++; } return months; }