public override DataTemplate SelectTemplate(object item, DependencyObject container) { CalendarButtonContent content = item as CalendarButtonContent; //if (IsGetDate) //{ if (content != null) { if (content.Date.DayOfWeek == DayOfWeek.Saturday || content.Date.DayOfWeek == DayOfWeek.Sunday) { //content.IsEnabled = false; content.Text = "S"; } } //Some days are special: //Thread.Sleep(3000); if (content.Date.Day == PubHoliday && content.ButtonType == CalendarButtonType.Date) { //content.Text = "current content"; content.IsEnabled = true; return(SpecialDay); } //} return(DefaultTemplate); }
public override DataTemplate SelectTemplate(object item, DependencyObject container) { CalendarButtonContent content = item as CalendarButtonContent; if ((content != null) && ((((content.Date.DayOfWeek == DayOfWeek.Saturday) || (content.Date.DayOfWeek == DayOfWeek.Sunday)) || (content.Date.Month == DateTime.Now.Month)) || (content.Date.Month == (DateTime.Now.Month + 2)))) { content.IsEnabled = false; } return(this.DefaultTemplate); }
public override DataTemplate SelectTemplate(object item, DependencyObject container) { CalendarButtonContent content = item as CalendarButtonContent; if (content != null) { if (content.Date.DayOfWeek == DayOfWeek.Saturday || content.Date.DayOfWeek == DayOfWeek.Sunday) { content.IsEnabled = false; } } return(DefaultTemplate); }
public override DataTemplate SelectTemplate(object item, DependencyObject container) { CalendarButtonContent content = item as CalendarButtonContent; if ((content != null) && ((content.Date.DayOfWeek == DayOfWeek.Saturday) || (content.Date.DayOfWeek == DayOfWeek.Sunday))) { content.IsEnabled = false; } if (((content.Date.Day % 11) == 0) && (content.ButtonType == CalendarButtonType.Date)) { return(this.SpecialDay); } return(this.DefaultTemplate); }
public override Style SelectStyle(object item, DependencyObject container) { // Add custom Tooltip for each calendar button Control control = container as Control; Leave objLeave = new Leave(); List <Leave> leaveList = new List <Leave>(); //FrmHumanResource objFrmHumanResource = null; //int EmployeeId = objFrmHumanResource.GetEmployeeId(); if (EmployeeId == "") { EmployeeId = "34,1034,1035,1036,1037,1038,1039,1040,1041,1042,1043,1044,1045"; } //int EmployeeId = 28; if (EmployeeId != "") { leaveList = objLeave.GetLeaveDetailsCalendarByEmployeeId(EmployeeId); if (control != null) { CalendarButtonContent buttonContent = (item as CalendarButtonContent); foreach (Leave selectedLeave in leaveList) { if (buttonContent.Date == Convert.ToDateTime(selectedLeave.LeaveStartDate)) { if ((buttonContent.Date.DayOfWeek != DayOfWeek.Sunday || buttonContent.Date.DayOfWeek != DayOfWeek.Saturday)) // && buttonContent.ButtonType != CalendarButtonType.Date) { control.ToolTip = new ToolTip() { Content = selectedLeave.LeaveStartDate + "\n" + selectedLeave.LeaveType + "\n" + selectedLeave.LeaveReason }; control.FontWeight = FontWeights.Bold; if (selectedLeave.LeaveType.Trim() == "Cassual Leave") { control.Background = System.Windows.Media.Brushes.Red; } else if (selectedLeave.LeaveType.Trim() == "Marriage Leave") { control.Background = System.Windows.Media.Brushes.Purple; } else if (selectedLeave.LeaveType.Trim() == "House Move Leave") { control.Background = System.Windows.Media.Brushes.Yellow; } else if (selectedLeave.LeaveType.Trim() == "Maternity Leave") { control.Background = System.Windows.Media.Brushes.Green; } else if (selectedLeave.LeaveType.Trim() == "Mortality Leave") { control.Background = System.Windows.Media.Brushes.Cyan; } else if (selectedLeave.LeaveType.Trim() == "Sick Leave") { control.Background = System.Windows.Media.Brushes.Orange; } else if (selectedLeave.LeaveType.Trim() == "Paternity Leave") { control.Background = System.Windows.Media.Brushes.BurlyWood; } else if (selectedLeave.LeaveType.Trim() == "Special Leave") { control.Background = System.Windows.Media.Brushes.LightGreen; } else if (selectedLeave.LeaveType.Trim() == "Study Leave") { control.Background = System.Windows.Media.Brushes.Blue; } } } } } } return(base.SelectStyle(item, container)); }