PeriodStart/End binding

4 posts, 0 answers
  1. Jerome
    Jerome avatar
    87 posts
    Member since:
    Aug 2010

    Posted 22 Jun 2012 Link to this post

    <telerik:RadTimeline
        PeriodStart="{Binding FromDate, Mode=TwoWay}"
        PeriodEnd="{Binding ThruDate, Mode=TwoWay}"
        VisiblePeriodStart="{Binding VisiblePeriodStart, Mode=TwoWay}"
        VisiblePeriodEnd="{Binding VisiblePeriodEnd, Mode=TwoWay}"
        StartPath="DateTime"
        DurationPath="Duration">
    </telerik:RadTimeline>

    From the ViewModel:

    public DateTime FromDate
    {
        get { return fromDate; }
        set { fromDate = value; OnPropertyChanged("FromDate"); }
    }
     
    public DateTime ThruDate
    {
        get { return thruDate; }
        set { thruDate = value; OnPropertyChanged("ThruDate"); }
    }

    I believe I'm doing this properly. When I set the value of FromDate and ThruDate in response to an async data load in the ViewModel, the Timeline doesn't update itself. It looks like the Slider is stuck on the far left, with no span, and no ability to change it.

    If however I do not put a Binding on the Timeline's PeriodEnd/Start properties, but hard code the exact same value that I would have otherwise set in the ViewModel, it works fine.

    What's up with this?

    [EDIT]

    I have sort of solved this, poorly, with the following code on my View:

    static void ViewModel_Changed(object sender, DependencyPropertyChangedEventArgs args)
    {
        var view = (PersonEventsView)sender;
        view.ViewModel.PropertyChanged += view.ViewModel_PropertyChanged;
    }
     
    void ViewModel_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e)
    {
        switch (e.PropertyName)
        {
            case "FromDate":
                Timeline.PeriodStart = ViewModel.FromDate;
                break;
            case "ThruDate":
                Timeline.PeriodEnd = ViewModel.ThruDate;
                break;
        }
    }


  2. Tsvetie
    Admin
    Tsvetie avatar
    1517 posts

    Posted 27 Jun 2012 Link to this post

    Hi Jerome,

    Your code looks correct and I am not sure what could be causing the problem. Basically, the scenario that you describe is very similar to our First Look demo and the demo works correctly. In case the problem persists, it will be best if you open a formal support ticket and send me a simple running project, demonstrating the problem you describe.

    Regards,
    Tsvetie
    the Telerik team

    Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

  3. DevCraft banner
  4. Jerome
    Jerome avatar
    87 posts
    Member since:
    Aug 2010

    Posted 05 Nov 2012 Link to this post

    I think I've sort of identified why this might happen. It looks like setting some of the Period* properties, or the VisiblePeriod* properties, actually results in the Timeline updating the other properties. So, when I declare a TwoWay binding, the Telerik control is actually going to unsetting the value I just set in my ViewModel, probably in relation to the order the bindings apply. I'll look closer, but I suspect Visible* is constrained to be WITHIN Period*. If so, if the Binding for Visible* sets before the binding for Period*, then the Visible properties probably don't get set (constrained by the current Period* settings), and result in them being pushed back into my ViewModel, as the incorrect value. 
  5. Tsvetie
    Admin
    Tsvetie avatar
    1517 posts

    Posted 07 Nov 2012 Link to this post

    Hello Jerome,

    You are correct - there is a requires precedence in setting the PeriodStart, PeriodEnd, VisiblePeriodStart and VisiblePeriodEnd properties. This requirement is a result of the coercing mechanism of the timeline control. The correct order is PeriodStart, PeriodEnd, VisiblePeriodStart, VisiblePeriodEnd.

    The TwoWay binding requirement is a result of the coercing as well.

    Greetings,
    Tsvetie
    the Telerik team

    Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

Back to Top