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
2085
Classes inheriting from DateTimeEntry are not used in Event Callbacks?
posted

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?

 

Parents
  • 30945
    Verified Answer
    Offline posted

    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

    TimelineCustomEventEntryIssue.zip
Reply Children