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

PeriodStart/End binding

3 Answers 99 Views
TimeLine
This is a migrated thread and some comments may be shown as answers.
Jerome
Top achievements
Rank 1
Jerome asked on 22 Jun 2012, 03:54 PM
<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;
    }
}


3 Answers, 1 is accepted

Sort by
0
Tsvetie
Telerik team
answered on 27 Jun 2012, 01:50 PM
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 >>

0
Jerome
Top achievements
Rank 1
answered on 05 Nov 2012, 05:13 PM
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. 
0
Tsvetie
Telerik team
answered on 07 Nov 2012, 01:48 PM
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.

Tags
TimeLine
Asked by
Jerome
Top achievements
Rank 1
Answers by
Tsvetie
Telerik team
Jerome
Top achievements
Rank 1
Share this question
or