I have a class that inherits from DateTimeEntry:
public class ConstraintDateTimeEntry : DateTimeEntry
I set a collection ObservableCollection<ConstraintDateTimeEntry> of these into the time line:
DateTimeSeries outageSeries = new DateTimeSeries();
outageSeries.Title ="Outage Periods";
outageSeries.DataSource = displayedOutageEntries;
outageSeries.DataMapping = "Time=Time;Duration=Duration;Title=Title;Details=Details";
outageSeries.Position = Position.TopOrLeft;
m_xamTimeline.Series.Add(outageSeries);
I have a right-click context menu setup on the DateTimeEvent's title that invokes an event callback with this logic:
ConstraintDateTimeEntry entry = ((menu.PlacementTargetResolved as Border).TemplatedParent as EventTitle).EventEntry as ConstraintDateTimeEntry;
This code results in a null "entry" variable because the type of the EventEntry property is DateTimeEntry, NOT ConstraintDateTimeEntry. Why do I get a type I never added to the series/timeline and how to I get which ConstraintDateTimeEntry corresponds to the title clicked on?
Hello Gary,
Thank you for your post. I have been looking into the issue that you have described and the reason for entry to be null is that the EventEntry property is returning a DateTimeEntry. When you are setting the DataSource property of the DateTimeSeries and you are setting the DataMapping, the XamTileline is creating a DateTimeEntry for each item of the DataSource and this items is the value of the EventEntry property of the EventTitle. The ConstraintDateTimeEntry object is the DataContext of the EventTitle and you can use the DataContext property in order to get the ConstraintDateTimeEntry object associate with the DateTimeEntry. Here is how you can implement this approach:
ConstraintDateTimeEntry entry = (menu.PlacementTargetResolved as Border).DataContext as ConstraintDateTimeEntry;
Also you can use the EventEntry property of the EventTitle, in order to get the ConstraintDateTimeEntry object. To do that, you can set the Entries property of the DateTimeSeries, instead of the DataSource and the DataMapping. The Entries property is form type ObservableCollection<DateTimeEntry> and you can create a collection of DateTimeEntry and add ConstraintDateTimeEntry in it. By doing so, the code snippet that you have posted, for getting the ConstraintDateTimeEntry object, will return the object that you need. I have created a sample application for you, based on the code snippets that you have provided, in order to show how you can implement the second approach.
Please let me know if you need any further assistance on the matter.
Sincerely,
Krasimir
Developer Support Engineer
Infragistics
www.infragistics.com/support
I am just checking if you require any further assistance on the matter.
Hi Krasimir,
Your suggestion worked as you described, thanks for your guidance!
Thank you for your reply. I am very glad that the approach I have suggested was helpful for you. Please let me know if you need any further assistance on the matter.