Quizzy example in code: Duplicate StartDate = startDate

2 posts, 1 answers
  1. Youngjae
    Youngjae avatar
    5 posts
    Member since:
    Jul 2012

    Posted 24 Nov 2012 Link to this post

    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;


  2. Answer
    Petar Kirov
    Admin
    Petar Kirov avatar
    425 posts

    Posted 28 Nov 2012 Link to this post

    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.

  3. UI for WPF is Visual Studio 2017 Ready
Back to Top