/// <summary> /// Finds <see cref="AppointmentItemsControl"/> and <see cref="TimeSlotItemsControl"/> in the template. /// </summary> public override void OnApplyTemplate() { base.OnApplyTemplate(); this.Scheduler = this.ParentOfType <RadScheduler>(); if (this.Scheduler != null && this.Scheduler.SchedulerPresenter != null) { this.Scheduler.SchedulerPresenter.SchedulerAppointmentsControls.Add(this); } if (this.appointmentItemsControl != null) { this.appointmentItemsControl.TimeSlotItemsControl = null; } this.TimeSlotItemsControl = this.GetTemplateChild(TimeSlotItemsControlName) as TimeSlotItemsControl; if (this.TimeSlotItemsControl != null) { this.TimeSlotItemsControl.SetBinding( ItemsControl.ItemsSourceProperty, new Binding("TimeSlots") { Source = this, Mode = BindingMode.OneWay }); this.TimeSlotItemsControl.SetBinding( TimeSlotItemsControl.SelectedTimeSlotProperty, new Binding("Scheduler.SelectedTimeSlot") { Source = this, Mode = BindingMode.TwoWay }); } this.appointmentItemsControl = this.GetTemplateChild(AppointmentItemsControlName) as AppointmentItemsControl; if (this.appointmentItemsControl != null) { this.appointmentItemsControl.SetBinding( ItemsControl.ItemsSourceProperty, new Binding("AppointmentSlots") { Source = this }); this.appointmentItemsControl.SetBinding( AppointmentItemsControl.SelectedAppointmentsProperty, new Binding("Scheduler.SelectedAppointments") { Source = this }); } if (this.appointmentItemsControl != null) { this.appointmentItemsControl.TimeSlotItemsControl = this.TimeSlotItemsControl; } this.AttachTimeSlots(); }
/// <summary> /// Provides the behavior for the Measure pass of Silverlight layout. Classes can override this method to define their own Measure pass behavior. /// </summary> /// <param name="availableSize">The available size that this object can give to child objects. Infinity can be specified as a value to indicate that the object will size to whatever content is available.</param> /// <returns> /// The size that this object determines it needs during layout, based on its calculations of child object allotted sizes. /// </returns> protected override Size MeasureOverride(Size availableSize) { // This is need for WPF to initialize ItemConteinerGenerator property. if (this.InternalChildren != null) { } int timeSlotsCount; bool isHorizontal = this.Orientation == Orientation.Horizontal; AppointmentItemsControl appointmentsItemsControl = this.AppointmentItemsControl; Size timeSlotSize = this.GetTimeSlotItemContentHostRenderSize(out timeSlotsCount); if (timeSlotSize.IsEmpty || timeSlotSize == new Size() || (this.previousAvailableSize != availableSize && !isHorizontal)) { this.previousAvailableSize = availableSize; if (timeSlotsCount > 0) { this.containersGenerated = false; } if (!isHorizontal) { this.RecycleAllAppointmentItems(); } return(base.MeasureOverride(availableSize)); } else { this.previousAvailableSize = availableSize; if (isHorizontal) { if (this.columns.Count == 0) { this.InitializeColumns(); } this.GenerateContainers(); } else { RadScheduler scheduler = this.AppointmentItemsControl != null ? this.AppointmentItemsControl.Scheduler : null; if (scheduler != null && scheduler.ActiveViewDefinition != null && scheduler.ActiveViewDefinition.TimeSlotLength != TimeSpan.Zero) { this.timeSlotTimeSpan = scheduler.ActiveViewDefinition.TimeSlotLength; } else { this.timeSlotTimeSpan = singleDayTimeSpan; } if (this.slots.Count == 0) { this.GenerateSlots(timeSlotsCount); } if (this.IsVirtualizing && this.InRecyclingMode) { this.HideShowMoreButtons(); } var source = this.AppointmentItemsControl.ItemsSource as AppointmentSlotCollection; for (int i = 0; i < timeSlotsCount; i++) { TimeSlotItemAppointments item = this.slots[i] as TimeSlotItemAppointments; this.GenerateContainers(item, source); } } if (double.IsInfinity(availableSize.Width) || double.IsInfinity(availableSize.Height)) { return(this.TimeSlotItemsControl.DesiredSize); } return(availableSize); } }
public AppointmentResizeManager(AppointmentItemsControl itemsControl) { this.itemsControl = itemsControl; }