Hi, I'm trying to set a tooltip on an Appointment in the XamScheduleView. I have learned that, in order to achieve this, I should define a Style for the ActivityToolTipPresenter, and set the Template property. In this template, I want to bind to some properties of the business object which is the data source for the appointment. I tried to create Appointment object like this:
Appointment appointment = new Appointment() { Id = id.ToString(), ... (more properties) ... , DataItem = businessObject };
Then, in the Style I tried to access the business object like this:
<Grid DataContext="{Binding Activity.DataItem.SomeProperty}" />
However, this binding doesn't work. Apparently, the DataItem no longer refers to my BusinessObject, but to itself instead (the Appointment object).
So, how can I achieve the desired effect?
Regards, Stefan
Hello Stefan,
I have attached a sample application that writes a Style for AppointmentPresenter to set a custom tooltip on an appointment. This application takes the ControlTemplate with the key “ActivityTemplate” from the generic.shared.xaml default style of the XamSchedule. A common directory for finding this default style is: C:\Program Files (x86)\Infragistics\2014.1\WPF\DefaultStyles\Schedule.
In this ControlTemplate, under the first grid and VisualStateGroup, there is another grid that I have named DSEAndrewGrid so you can find it easily in the attached sample. If you set the Tooltip property on this grid, you can set a custom tooltip on an appointment by setting this ControlTemplate to the Template property of the AppointmentPresenter style mentioned above.
The DataItem of an appointment is the appointment, so to bind a tooltip to a business object, I would actually recommend writing a custom class that extends Appointment and add a public object property that you can set to your business object. After this, you can bind the grid’s tooltip property to MySettableDataItemProperty.SomeProperty.
The attached sample application demonstrates the above.
Please let me know if you have any other questions or concerns on this matter.
Sincerely,AndrewDeveloper Support Engineer IInfragistics Inc.www.infragistics.com/support
Just checking in, did you have any other questions or concerns on this matter?
Hi Andrew,
Sorry for my late response, I've been very busy lately. I noticed that in your sample you created a custom class which derives from Appointment. This class has one object property, which is kind of a Tag-like thing. This is actually a trick that I have already tried before. But by doing it this way I have discovered that there may be a memory leak in the control. It seems the Appointment objects (or their derived classes) are not cleared from memory when refreshing the data on the control (we are continuously refreshing the data in our application). I will be creating a new post for this soon, because this problem occurs even when using the base Appointment class, without the SettableDataItem object. I will post a link to this post here.
http://es.infragistics.com/community/forums/p/92574/457630.aspx#457630