1
Vote

TimelinePanel: BeginDate is set to 31/12/9999 when there are no children present.

description

TimelinePanel sets the BeginDate to DateTime.Max when there are no children present. This can be fixed by modifying Size MeasureOverride(Size availableSize) method.
 protected override Size MeasureOverride( Size availableSize )
    {
      DateTime calcBeginDate = DateTime.MaxValue; // max value is set
      DateTime calcEndDate = DateTime.MinValue;

      foreach( UIElement child in InternalChildren ) // if there aren't any children present
      {
        DateTime date = GetDate( child );
        DateTime dateEnd = GetDateEnd( child );

        if( date < calcBeginDate )
        {
          calcBeginDate = date;
        }

        if( date > calcEndDate )
        {
          calcEndDate = date;
        }

        if( dateEnd > calcEndDate )
        {
          calcEndDate = dateEnd;
        }
      }

      if( BeginDate == DateTime.MinValue ) // this condition is always true the first time control is loaded.
      {
        BeginDate = calcBeginDate; // if there aren't any children then BeginDate becomes DateTime.Max and stays at that value.
      }

comments