This is a migrated thread and some comments may be shown as answers.

Quizzy example in code: Duplicate StartDate = startDate

1 Answer 43 Views
TimeLine
This is a migrated thread and some comments may be shown as answers.
Youngjae
Top achievements
Rank 1
Youngjae asked on 24 Nov 2012, 02:26 PM
Hello.

In WPF RadTimeline First Look example (presidents list)
UpdateCurrentPage() method in ExampleViewModel.cs file has duplicate variable settings as below.

Is there any reason?

this.StartDate = startDate;
this.EndDate = endDate;
this.StartDate = startDate;
 
this.VisibleStartDate = startDate;
this.VisibleEndDate = endDate;
this.VisibleStartDate = startDate;


1 Answer, 1 is accepted

Sort by
0
Accepted
Petar Kirov
Telerik team
answered on 28 Nov 2012, 03:22 PM
Hello Youngjae,

These duplicate settings of the properties are required because the RadTimeline (and RadTimeBar) internally coerces the PeriodStart/End, VisiblePeriodStart/End and SelectionStart/End properties. For example if PeriodStart is set to a date after PeriodEnd by the user, then the PeriodStart is set to PeriodEnd internally afterwards.

There is a required precedence of the Timeline's (and TimeBar's) properties. This means that the Start Time should always be set before the End Time. The optimal way to set them is in the following order: 
  1. PeriodStart
  2. PeriodEnd
  3. VisiblePeriodStart
  4. VisiblePeriodEnd
  5. SelectionStart
  6. SelectionEnd

In order to make more clear the code from the example I've rewritten in code snippet below: 
//PeriodStart and PeriodEnd
if (this.EndDate < startDate)
{
    this.EndDate = endDate;
    this.StartDate = startDate;
}
else
{
    this.StartDate = startDate;
    this.EndDate = endDate;
}
 
//VisiblePeriodStart and VisiblePeriodEnd
if (this.VisibleEndDate < newStartDate)
{
    this.VisibleEndDate = endDate;
    this.VisibleStartDate = startDate;
}
else
{
    this.VisibleStartDate = startDate;
    this.VisibleEndDate = endDate;
}
 
All the best,
Petar Kirov
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

Tags
TimeLine
Asked by
Youngjae
Top achievements
Rank 1
Answers by
Petar Kirov
Telerik team
Share this question
or