RadTimeBar and MVVM

5 posts, 0 answers
  1. Robert Bevis
    Robert Bevis avatar
    4 posts
    Member since:
    Oct 2009

    Posted 15 May 2012 Link to this post

    Hi,

    I'm using radtimebar on version 2012.1.514.1050 and I'm having an issue with the behaviour of the MinSelectionRange and MaxSelectionRange.
    I've this MVVM scenario and seems that the MinSelectionRange and MaxSelectionRange does not work and allows any selection. The same scenario with static properties (like on firtst look sample) works just fine.

    My RadtimeBar code is:

        <telerik:RadTimeBar Name="timeBar1" Grid.Row="1" Grid.Column="0" Grid.ColumnSpan="2" Margin="10,10,10,10"
                                        PeriodStart="{Binding Path=PeriodStart,Mode=TwoWay}" PeriodEnd="{Binding Path=PeriodEnd,Mode=TwoWay}"
                                        VisiblePeriodStart="{Binding Path=VisiblePeriodStart,Mode=TwoWay}" VisiblePeriodEnd="{Binding Path=VisiblePeriodEnd,Mode=TwoWay}"  
                                        SelectionStart="{Binding Path=SelectionStart,Mode=TwoWay}" SelectionEnd="{Binding Path=SelectionEnd,Mode=TwoWay}" 
                                        IsSnapToIntervalEnabled="true"
                                        MinSelectionRange="3.00:00:00"
                                        MaxSelectionRange="14.00:00:00">
                <telerik:RadTimeBar.Intervals>
                    <telerik:QuarterInterval />
                    <telerik:MonthInterval />
                    <telerik:WeekInterval />
                    <telerik:DayInterval />
                    <telerik:HourInterval/>
                </telerik:RadTimeBar.Intervals>
                <Grid>
                    <telerik:RadColumnSparkline ItemFill="Salmon" ItemsSource="{Binding Alerts}" XValuePath="TimeStamp" YValuePath="Count" Opacity="0.7"/>
                    <telerik:RadLinearSparkline LineStroke="Blue" ItemsSource="{Binding Events}" XValuePath="TimeStamp" YValuePath="Count" LineShapeStyle="{StaticResource SparklineLineStyle}" Opacity="0.9" />
                </Grid>
                                        MinSelectionRange="3.00:00:00"
                                        MaxSelectionRange="14.00:00:00">
  2. Robert Bevis
    Robert Bevis avatar
    4 posts
    Member since:
    Oct 2009

    Posted 16 May 2012 Link to this post

    Think I'll just open a ticket with this since I've receive no feedback

    Thanks
  3. DevCraft banner
  4. Tsvetie
    Admin
    Tsvetie avatar
    1517 posts

    Posted 17 May 2012 Link to this post

    Hi,

    We are aware of this problem and it is already on our ToDo list. You can vote and track the progress on the problem here.

    For the time being, the only workaround that I can offer you, is to bind the selection range properties as well and set them, after you have set values for the PeriodStart and PeriodEnd properties. For example:

    <telerik:RadTimeBar x:Name="timebar1" Width="700" Height="300"
                        PeriodStart="{Binding StartDate, Mode=TwoWay}"
                        PeriodEnd="{Binding EndDate, Mode=TwoWay}"
                        VisiblePeriodStart="{Binding VisibleStart, Mode=TwoWay}"
                        VisiblePeriodEnd="{Binding VisibleEnd, Mode=TwoWay}"
                        MinSelectionRange="{Binding MinSelection, Mode=TwoWay}"
                        MaxSelectionRange="{Binding MaxSelection, Mode=TwoWay}">

    StartDate = DateTime.Today;
    EndDate = StartDate.AddDays(1);
     
    DateTime now = DateTime.Now;
    VisibleStart = now.AddMinutes(-30);
    VisibleEnd = now.AddMinutes(30);
     
    MinSelection = TimeSpan.FromMinutes(30);
    MaxSelection = TimeSpan.FromMinutes(60);
    Regards,
    Tsvetie
    the Telerik team

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

  5. Robert Bevis
    Robert Bevis avatar
    4 posts
    Member since:
    Oct 2009

    Posted 17 May 2012 Link to this post

    Hi,

    Thanks for the feedback. Sorry but I'm not understanding your workaround.
    You are saying " the only workaround that I can offer you, is to bind the selection range properties as well and set them, after you have set values for the PeriodStart and PeriodEnd properties "

    And on your sample,  you have remove the SelectionStart and SelectionEnd that I has on my sample...
    Can you clarify a little better the workaround ?

    Thanks
  6. Tsvetie
    Admin
    Tsvetie avatar
    1517 posts

    Posted 21 May 2012 Link to this post

    Hello,

    I have attached my test code in order to demonstrate the workaround that I suggested. I added binding expressions for the SelectionStart and SelectionEnd properties as well.

    Basically, the problem comes from the fact that the MinSelectionRange and MaxSelectionRange properties and coerced against the whole period - [PeriodStart; PeriodEnd), and that is why, you should make sure that you set them after you have set the whole period.

    Kind regards,
    Tsvetie
    the Telerik team

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

Back to Top
DevCraft banner