when period changed

2 posts, 0 answers
  1. Xiaojun
    Xiaojun avatar
    7 posts
    Member since:
    Nov 2011

    Posted 23 Feb 2012 Link to this post

    I use the time bar to show orders and invoices, but it happens some problems. All data bind from view model. Orders will be added a record which order date is period start if orders have not this. The same as period end. The SelectionStart and SelectionEnd are calculated in view model. Details show in the attached picture.

    Best regards

         
    PeriodEnd = OptionPeriodEnd;
    PeriodStart = OptionPeriodStart;
    Criteria.EndDate = PeriodEnd;
    SelectionEnd = Criteria.EndDate.Value;
    var startDate = new DateTime(PeriodEnd.Year, PeriodEnd.Month, 1).AddMonths(-3);
    Criteria.StartDate = PeriodStart.CompareTo(startDate) < 0 ? startDate : PeriodStart;
    SelectionStart = Criteria.StartDate.Value;
     

    <telerik:RadTimeBar x:Name="timeBar"
                                    IsSnapToIntervalEnabled="True"
                                    MinZoomRange="7.00:00:00"
                                    PeriodStart="{Binding PeriodStart, Mode=OneWay}"
                                    PeriodEnd="{Binding PeriodEnd, Mode=OneWay}"
                                    MinSelectionRange="7.00:00:00"
                                    SelectionStart="{Binding SelectionStart, Mode=TwoWay}"
                                    SelectionEnd="{Binding SelectionEnd, Mode=TwoWay}"
                                    BorderThickness="0"
                                    Margin="10,10,10,0"
                                    Grid.Row="1"
                                    Grid.ColumnSpan="2"
                                    MinHeight="100"
                                    MaxHeight="130"
                                    Foreground="{StaticResource text}"
                                    Style="{StaticResource RadTimeBarStyle}"
                                    Opacity="1">
                    <i:Interaction.Triggers>
                        <i:EventTrigger EventName="SelectionChanged">
                            <i:InvokeCommandAction Command="{Binding ReloadAllCommand}" />
                        </i:EventTrigger>
                    </i:Interaction.Triggers>
                    <telerik:RadTimeBar.Intervals>
                        <telerik:YearInterval/>
                        <telerik:QuarterInterval/>
                        <telerik:MonthInterval/>
                        <telerik:WeekInterval/>
                    </telerik:RadTimeBar.Intervals>
                    <Grid>
                        <telerik:RadLinearSparkline x:Name="ActualTrend"
                                                    FirstPointBrush="{StaticResource invoice}"
                                                    Foreground="{StaticResource text}"
                                                    LastPointBrush="{StaticResource invoice}"
                                                    MarkersBrush="{x:Null}"
                                                    NegativePointBrush="{StaticResource invoice}"
                                                    AutoRange="False"
                                                    XValuePath="OrderDate"
                                                    YValuePath="InvoiceAmount"
                                                    LineStroke="{StaticResource invoice}"
                                                    ItemsSource="{Binding Orders, Mode=OneWay}"
                                                    Visibility="Visible"/>
                        <telerik:RadLinearSparkline x:Name="TargetTrend"
                                                    FirstPointBrush="{StaticResource order}"
                                                    Foreground="{StaticResource text}"
                                                    LastPointBrush="{StaticResource order}"
                                                    MarkersBrush="{x:Null}"
                                                    NegativePointBrush="{StaticResource order}"
                                                    XValuePath="OrderDate"
                                                    YValuePath="OrderAmount"
                                                    LineStroke="{StaticResource order}"
                                                    ItemsSource="{Binding Orders, Mode=OneWay}">
                        </telerik:RadLinearSparkline>
                    </Grid>
                </telerik:RadTimeBar>
  2. Xiaojun
    Xiaojun avatar
    7 posts
    Member since:
    Nov 2011

    Posted 24 Feb 2012 Link to this post

    I have found the problem. PeriodStart and PeriodEnd must be twoway and the value of PeriodStart must be set earlier than PeriodEnd. The same as SelectionStart and SelectionEnd.
    Thank you.
  3. DevCraft banner
Back to Top