Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
1465
XamDayView
posted

Hi,

 

I was wanting to know how I can change the colour of the text on the appointment. I have tried to do this by doing the following, see below.

This works as expected when the appointment is initially created, but if the appointment is edited and something changes which needs to change the colour of the text of the appointment it does not do so. I think it is because the appointment loaded event is not called when appointment updates or perhaps the flag I am using to change my colour does not fire a change as it is not native to the infragistics schedule appointment.

 

Please advise,

kind regards,
Anne

 

private void AppointmentPresenter_Loaded(object sender, RoutedEventArgs e)

        {           

           

var presenter = sender as AppointmentPresenter;

           

if (presenter == null)

               

return;

           

//Create a new DropTarget object.

           

DropTarget dropTarget = new DropTarget();

            dropTarget.IsDropTarget =

true;

            dropTarget.DropTargetMarkerBrush = System.Windows.Media.

Brushes.Black;

           

//Make the Node a Drop Target.

           

DragDropManager.SetDropTarget(presenter, dropTarget);

           

var calendarAppointment = presenter.Activity as CustomDiaryAppointment;

           

if (calendarAppointment == null || calendarAppointment.AppointmentDataItem == null)

               

return;

           

var activityContentPanel = Infragistics.Windows.Utilities.GetDescendantFromType(presenter as DependencyObject,

               

typeof(ActivityContentPanel), false) as ActivityContentPanel;

           

if (activityContentPanel != null)

            {

           

StackPanel wrapStackPanel = activityContentPanel.Children.OfType<StackPanel>().FirstOrDefault(s =>

                s.Tag

is string && (string)s.Tag == OuterStackPanelTag);

           

if (wrapStackPanel == null)

                wrapStackPanel = CreateAndInsertWrappedContentStackPanel(activityContentPanel, calendarAppointment.AppointmentDataItem);

           

StackPanel sp = Infragistics.Windows.Utilities.GetDescendantFromType(wrapStackPanel as DependencyObject, typeof(StackPanel), false) as StackPanel;

           

TextBlock tb = Infragistics.Windows.Utilities.GetDescendantFromType(wrapStackPanel as DependencyObject, typeof(TextBlock), false) as TextBlock;

           

// Show incomplete historic appointments in red

           

if ((!calendarAppointment.AppointmentDataItem.IsCompleted) &&

                calendarAppointment.AppointmentDataItem.EndDateTime <=

DateTime.Now &&

                calendarAppointment.AppointmentDataItem.AppointmentType.IsCompletable)          

                tb.Foreground =

Brushes.Red;           

           

else

                tb.Foreground =

Brushes.Black;           

            tb.FontWeight =

FontWeights.Normal;

        }

        }