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)
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.FontWeight =
FontWeights.Normal;
}
I am just checking your progress on the issue. Could you provide me a sample project so I could look further into it for you?
Thank you.
Hello Anne,
Thank you for the provided details and please excuse me for the delay. The Loaded event will only fire when new appointment is added to the collection as you have noticed. If you are creating custom dialog based on the ScheduleDialogFactoryBase class overriding the CreateActivityDialog would allow you to access the activities and their events should also be fired for the custom ones. Would you mind sharing a sample project or at least a code snippet of your custom dialog so I could look into it too?
Hi Maria,
I thought I would give more information which might explain better what is happening. I have a custom appointment dialog, which I launch by cancelling the infragistics one as follows
private void OnActivityDialogDisplaying(object sender, ActivityDialogDisplayingEventArgs e)
e.Cancel =true;
LaunchCustomDialog();
This all works fine, when the user hits okay on my custom dialog, it saves the appointment and I rebind the list of appointments to the appointmentsource on the datamanager and it refreshes the xamdayview showing the new appointment.
I want to make the text of the appointment different colours depending on the type of appointment created, based on my business rules, in order to do so I need to catch were the appointment is loaded to the appointment source to do so. I have tried the appointmentpresenter loaded event but this does not work. So what I wanted to do was do it in the datamanager activity adding event, but this event is never fired as I am using a custom appointment dialog. Is there a way I can get my custom dialog to fire this or do you know another way to achieve this. I tried adding the following to my ok button but as follows but it does nothing.
<Button x:Name="btnOk" Command="{Binding Path=SaveCommand}" Height="23" Width="75" Margin="0,0,105,5" HorizontalAlignment="Right" VerticalAlignment="Bottom" Content="OK" RenderTransformOrigin="0.5,2.119" Grid.Column="1">
<ig:Commanding.Command>
<igPrim:ActivityDialogCoreCommandSource EventName="Click" CommandType="SaveAndClose"/>
</ig:Commanding.Command>
Any help would be appreciated.
</Button>
>
I have tried all the activity events and can't seem to get them to fire on Adding. It only fires on changing when you drag an appointment, not exactly what I want.
kind regards,
Anne
Thank you for your feedback Anne. I will be looking for your response.