Back to Devexpress

SchedulerControl.CustomAppointmentBackground Event

wpf-devexpress-dot-xpf-dot-scheduling-dot-schedulercontrol-27c9299f.md

latest5.3 KB
Original Source

SchedulerControl.CustomAppointmentBackground Event

Allows you to customize the appointments’ appearance by changing their background color.

Namespace : DevExpress.Xpf.Scheduling

Assembly : DevExpress.Xpf.Scheduling.v25.2.dll

NuGet Package : DevExpress.Wpf.Scheduling

Declaration

csharp
[Browsable(false)]
public event CustomAppointmentBackgroundEventHandler CustomAppointmentBackground
vb
<Browsable(False)>
Public Event CustomAppointmentBackground As CustomAppointmentBackgroundEventHandler

Event Data

The CustomAppointmentBackground event's data class is CustomAppointmentBackgroundEventArgs. The following properties provide information specific to this event:

PropertyDescription
AppointmentItemProvides access to the current appointment.
BackgroundGets or sets a background color for the appointment.
SourceObjectProvides access to the appointments’ source object.

Remarks

The CustomAppointmentBackground event is raised when the Scheduler is loaded. Handle the CustomAppointmentBackground event to change the background color of the desired appointments. Access the appointment using the CustomAppointmentBackgroundEventArgs.AppointmentItem property. Use the CustomAppointmentBackgroundEventArgs.Background property to change the background color.

Example

View Example

vb
Private Sub SchedulerControl_CustomAppointmentBackground(ByVal sender As Object, ByVal e As CustomAppointmentBackgroundEventArgs)
    'Change the recurrent appointments' background to blanched almond color,
    'and other appointments - to rosy brown 
    e.Background = If(e.AppointmentItem.Type = AppointmentType.Occurrence, New SolidColorBrush(Colors.BlanchedAlmond), New SolidColorBrush(Colors.RosyBrown))

    'Change all-day appointments' background:
    e.Background = If(e.AppointmentItem.AllDay = True, New SolidColorBrush(Colors.Tomato), e.Background)
End Sub
xaml
<dxsch:SchedulerControl x:Name="scheduler" CommandBarStyle="Ribbon" 
                        GroupType="Resource" 
                        FirstDayOfWeek="Monday"                                 
                        ActiveViewIndex="0" CustomAppointmentBackground="SchedulerControl_CustomAppointmentBackground">
csharp
private void SchedulerControl_CustomAppointmentBackground(object sender, CustomAppointmentBackgroundEventArgs e)
{
    //Change the recurrent appointments' background to blanched almond color,
    //and other appointments - to rosy brown 
    e.Background = (e.AppointmentItem.Type == AppointmentType.Occurrence) ?
    new SolidColorBrush(Colors.BlanchedAlmond) : new SolidColorBrush(Colors.RosyBrown);

    //Change all-day appointments' background:
    e.Background = (e.AppointmentItem.AllDay == true) ? new SolidColorBrush(Colors.Tomato) : e.Background;
}

The following code snippet (auto-collected from DevExpress Examples) contains a reference to the CustomAppointmentBackground event.

Note

The algorithm used to collect these code examples remains a work in progress. Accordingly, the links and snippets below may produce inaccurate results. If you encounter an issue with code examples below, please use the feedback form on this page to report the issue.

wpf-scheduler-handle-customappointmentbackground-event-to-change-appointment-background/CS/CustomAppointmentBackground/MainWindow.xaml#L15

xml
FirstDayOfWeek="Monday"
                    ActiveViewIndex="0" CustomAppointmentBackground="SchedulerControl_CustomAppointmentBackground">
<dxsch:DayView x:Name="dayView1" DayCount="2" ResourcesPerPage="2" TopRowTime="9:0:0"/>

See Also

SchedulerControl Class

SchedulerControl Members

DevExpress.Xpf.Scheduling Namespace