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;

        }

        }

Parents
No Data
Reply
  • 17475
    Offline posted

    Hello Anne, 

    Thank you for posting! 

    I have been looking into your description and I could suggest you a few approaches to change the foreground color of an appointment. You can use the default style for the AppointmentPresenter that is defined in the generic.shared.xaml file in C:\Program Files (x86)\Infragistics\2013.2\WPF\DefaultStyles\Schedule. Modifying the ActivityTemplate will allow you to change the text representation.

    Another approach would be using the LayoutUpdated event and applying your custom logic there. Please note that this event is fired not only when an appointment has been updated but also when there is other interaction with an UI element – selection, added or deleted items, etc.

    A possible solution would be handling the ActivityChanged, ActivityAdded and ActiityRemoved of the XamScheduleDataManager and apply the changes there as this will not restricts you only to the appointments loading.

    I hope this information is helpful. Please feel free to let me know if you have any questions or concerns.

Children