/// <summary>
        /// Remove all the attached events and close the adorner and its control.
        /// </summary>
        private void AdornerClose()
        {
            if (_adorner != null)
            {
                _adorner.Control = null;

                // remove adorner
                _adornerLayer.Remove(_adorner);
                _adornerLayer = null;
                _adorner      = null;
            }
        }
        /// <summary>
        /// This Handles the ScheduledAppointment event of the AppointmentDataGrid control. This event is triggered when an item selection is made.
        /// This is XAML bound in Appointments.xaml
        ///       <customcontrols:AppointmentDataGrid ...customcontrols:AppointmentListView.ScheduledAppointment  ="AppointmentDataGrid_ScheduledAppointment"...
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="args">The <see cref="ScheduledAppointmentEventArgs"/> instance containing the event data.</param>
        private void AppointmentDataGrid_ScheduledAppointment(object sender, ScheduledAppointmentEventArgs args)
        {
            AdornerClose();
            AppointmentDataGrid fe = (AppointmentDataGrid)sender;

            ((ICloseable)DataContext).RequestClose += Appointments_RequestClose;

            // The appointmentKey comes directly from the selected listview element.
            IVisit visit = (IVisit)args.appointmentKey;

            // Must set the selected visit in the AppointmentEditor before the bindings of the adorner bind it to the DataGridAnnotationControl.
            // RaiseCommand here causes the "Command" (defined below) of the Appointments.XAML to call the RelayCommand via the DoctorView.Xaml.
            // The Command Target is SelectedVisit is the AppointmentEditor.cs.
            RaiseVisitCommand(visit);

            // Creation of the adorner will create the DatGridAnnotationControl and immediately create the bindings.
            _adorner = new DataGridAnnotationAdorner(fe);

            // put adorner into the adornerlayer.
            InstallAdorner(fe, _adorner);
        }