TimeBar Dates will not Bind Properly

4 posts, 0 answers
  1. Tom
    Tom avatar
    11 posts
    Member since:
    Jan 2012

    Posted 27 Jan 2012 Link to this post

    I am having trouble getting values to bind to a timebar.

    Here is the XAML for my test page:
    <Grid x:Name="LayoutRoot">
        <Grid.RowDefinitions>
            <RowDefinition Height="*"></RowDefinition>
            <RowDefinition Height="*"></RowDefinition>
        </Grid.RowDefinitions>
        <telerik:RadTimeBar Name="timeBar1" Grid.Row="0"
                PeriodStart="{Binding PeriodStart}"
                PeriodEnd="{Binding PeriodEnd}"
                SelectionStart="{Binding SelectionStart}" 
                SelectionEnd="{Binding SelectionEnd}"
                MinSelectionRange="2.00:00:00"
                MaxSelectionRange="90.00:00:00"
                IsSnapToIntervalEnabled="False">
            <telerik:RadTimeBar.Intervals>
                <telerik:YearInterval />
                <telerik:QuarterInterval />
                <telerik:MonthInterval />
                <telerik:WeekInterval />
                <telerik:DayInterval />
                <telerik:HourInterval/>
            </telerik:RadTimeBar.Intervals>
        </telerik:RadTimeBar>
        <telerik:RadTimeBar Name="timeBar2" Grid.Row="1"
                PeriodStart="10/1/2010"
                PeriodEnd="1/27/2012"
                SelectionStart="12/25/2011" 
                SelectionEnd="1/27/2012"
                MinSelectionRange="2.00:00:00"
                MaxSelectionRange="90.00:00:00"
                IsSnapToIntervalEnabled="False">
            <telerik:RadTimeBar.Intervals>
                <telerik:YearInterval />
                <telerik:QuarterInterval />
                <telerik:MonthInterval />
                <telerik:WeekInterval />
                <telerik:DayInterval />
                <telerik:HourInterval/>
            </telerik:RadTimeBar.Intervals>
        </telerik:RadTimeBar>
    </Grid>

    timebar1 does not render properly, timebar2 does render correctly.

    Here is the DataContext model:
    public class testtimebarclass
        {
            public DateTime PeriodStart { get; set; }
            public DateTime PeriodEnd { get; set; }
            public DateTime SelectionStart { get; set; }
            public DateTime SelectionEnd { get; set; }
        }

    Is there something obvious I am missing here?
  2. Tsvetie
    Admin
    Tsvetie avatar
    1517 posts

    Posted 01 Feb 2012 Link to this post

    Hi Tom,

    Because of the coercing mechanism of RadTimeBar, you have to use TwoWay binding, when binding the period properties. I have attached a simple test page, based on the code you provided, demonstrating the changes you need to make.

    All the best,
    Tsvetie
    the Telerik team

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

  3. DevCraft banner
  4. Kirk
    Kirk avatar
    28 posts
    Member since:
    Jun 2012

    Posted 16 Feb 2012 Link to this post

    I am doing this same thing for a project I am working on right now.

    The problem I am having is that even when I two way, if the selection is changed by clicking on the time bar it breaks the binding.
  5. Tsvetie
    Admin
    Tsvetie avatar
    1517 posts

    Posted 21 Feb 2012 Link to this post

    Hi Kirk,

    I am not quite sure I understand the problem that you describe. From the provided information, I understand that, in case you use TwoWay binding, the timebar renders correctly. And once you change the selection by clicking on the timebar, the problem occurs. I could not, however, understand what the problem is exactly. When I tested the code that I attached in my previous post, the control behaved as expected - the selection simply changed.

    Could you please explain in detail the result that you get and the one that you are after. It will be best, is you send me you code as well and information on the concrete version of the controls that you use.

    Kind regards,
    Tsvetie
    the Telerik team
    Sharpen your .NET Ninja skills! Attend Q1 webinar week and get a chance to win a license! Book your seat now >>
Back to Top