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

TimeBar / Sparkline - ItemsSource is updated and TimeBar headers do not reflect changes...

6 Answers 100 Views
TimeBar
This is a migrated thread and some comments may be shown as answers.
Rob
Top achievements
Rank 1
Rob asked on 30 Mar 2012, 08:37 PM

I have a basic RadTimeBar/RadColumnSparkline combo with a viewmodel data context.  When I update the "intervaltype", my ItemsSource is updated (click the "Change Data" button).  The RadColumnSparkline updates, but the headers in the RadTimeBar are no longer in sync.  As soon as I touch the RadTimeBar scrollbar everything seems to redraw itself properly...

<StackPanel x:Name="LayoutRoot" Background="Pink">
   <Button Click="ChangeData" Content="Change Data" />
   <telerik:RadTimeBar x:Name="timeBar" Height="300" Width="800" PeriodStart="{Binding PeriodStart, Mode=TwoWay}"
PeriodEnd="{Binding PeriodEnd, Mode=TwoWay}" SelectionStart="{Binding SelectionStart, Mode=TwoWay}" SelectionEnd="{Binding SelectionEnd, Mode=TwoWay}" IsSnapToIntervalEnabled="True" 
   >
      <telerik:RadTimeBar.Intervals>
         <telerik:CenturyInterval IntervalSpans="1" />
         <telerik:DecadeInterval />
         <telerik:YearInterval IntervalSpans="1" />
         <!--telerik:QuarterInterval /-->
         <telerik:MonthInterval IntervalSpans="1,3" />
         <!--telerik:WeekInterval IntervalSpans="1" /-->
         <telerik:DayInterval IntervalSpans="1,7" />
         <!--<telerik:HourInterval IntervalSpans="1" />-->
      </telerik:RadTimeBar.Intervals>
      <telerik:RadColumnSparkline x:Name="columnSparkline" ItemsSource="{Binding Points}" XValuePath="XValue" YValuePath="YValue" ColumnLayoutMode="Between" ColumnWidthPercent="0.8" EmptyPointBehavior="ShowAsZero" AutoRange="False" MinYValue="0" MaxYValue="{Binding MaxYValue}" />
   </telerik:RadTimeBar>
</StackPanel>


namespace SilverlightApplication10
{
    public partial class MainPage : UserControl
    {
        public VM vm = new VM();
        public MainPage()
        {
            InitializeComponent();
            this.Loaded += new RoutedEventHandler(MainPage_Loaded);
        }
        void MainPage_Loaded(object sender, RoutedEventArgs e)
        {
            vm.PeriodStart = new DateTime(2012, 1, 1);
            vm.PeriodEnd = new DateTime(2012, 3, 1);
            vm.IntervalType = IntervalType.Daily;
            this.DataContext = vm;
        }
        private void ChangeData(object sender, RoutedEventArgs e)
        {
            vm.IntervalType = vm.IntervalType == IntervalType.Daily ? IntervalType.Monthly : IntervalType.Daily;
        }
    }
 
    public enum IntervalType
    {
        Daily,
        Monthly
    }
 
    public class VM : Notify
    {
        private void RefreshDataPoints()
        {
            ObservableCollection<Point> p = new ObservableCollection<Point>();
            Random r = new Random();
            if (this.IntervalType == IntervalType.Daily)
            {
                this.PeriodEnd = new DateTime(2012, 3, 1);
                for (DateTime c = this.PeriodStart; c < this.PeriodEnd; c = c.AddDays(1))
                {
                    p.Add(new Point() { XValue = c, YValue = r.Next(0, 100) });
                }
            }
            else
            {
                this.PeriodEnd = new DateTime(2012, 4, 1);
                p.Add(new Point() { XValue = new DateTime(2012, 1, 1), YValue = r.Next(0, 100) });
                p.Add(new Point() { XValue = new DateTime(2012, 2, 1), YValue = r.Next(0, 100) });
                p.Add(new Point() { XValue = new DateTime(2012, 3, 1), YValue = r.Next(0, 100) });
            }
            this.Points = p;
        }
        private IntervalType _IntervalType = IntervalType.Daily;
        public IntervalType IntervalType
        {
            get
            {
                return this._IntervalType;
            }
            set
            {
                this._IntervalType = value;
                RaisePropertyChanged("IntervalType");
                RefreshDataPoints();
            }
        }
        private DateTime _PeriodStart = DateTime.MinValue;
        public DateTime PeriodStart
        {
            get
            {
                return this._PeriodStart;
            }
            set
            {
                this._PeriodStart = value;
                RaisePropertyChanged("PeriodStart");
                RaisePropertyChanged("SelectionStart");
            }
        }
        private DateTime _PeriodEnd = DateTime.MaxValue;
        public DateTime PeriodEnd
        {
            get
            {
                return this._PeriodEnd;
            }
            set
            {
                this._PeriodEnd = value;
                RaisePropertyChanged("PeriodEnd");
                RaisePropertyChanged("SelectionEnd");
            }
        }
        public DateTime SelectionStart
        {
            get
            {
                return this.PeriodStart;
            }
        }
        public DateTime SelectionEnd
        {
            get
            {
                return this.PeriodEnd;
            }
        }
        private ObservableCollection<Point> _Points = new ObservableCollection<Point>();
        public ObservableCollection<Point> Points
        {
            get
            {
                return this._Points;
            }
            set
            {
                this._Points = value;
                RaisePropertyChanged("Points");
                RaisePropertyChanged("MaxYValue");
            }
        }
        public int MaxYValue
        {
            get
            {
                return (this.Points == null || this.Points.Count() == 0 ? 0 : this.Points.Max(itm => itm.YValue));
            }
        }
    }
 
    public class Point : Notify
    {
        private DateTime _XValue = DateTime.MinValue;
        public DateTime XValue
        {
            get
            {
                return this._XValue;
            }
            set
            {
                this._XValue = value;
                RaisePropertyChanged("XValue");
            }
        }
        private int _YValue = 0;
        public int YValue
        {
            get
            {
                return this._YValue;
            }
            set
            {
                this._YValue = value;
                RaisePropertyChanged("YValue");
            }
        }
    }
 
    public class Notify : INotifyPropertyChanged
    {
        public event PropertyChangedEventHandler PropertyChanged;
        protected void RaisePropertyChanged(string propertyName)
        {
            PropertyChangedEventHandler propertyChanged = this.PropertyChanged;
            if ((propertyChanged != null))
            {
                propertyChanged(this, new PropertyChangedEventArgs(propertyName));
            }
        }
    }
 
 
}

 

6 Answers, 1 is accepted

Sort by
0
Rob
Top achievements
Rank 1
answered on 30 Mar 2012, 08:48 PM
Forgot to attach my images...
0
Tsvetie
Telerik team
answered on 05 Apr 2012, 12:48 PM
Hi Rob,

Thank you for bringing the problem to our attention. I forwarded it to our developers and we will fix it for the next release. The fix will be part of the latest internal build that we will upload next week as well.

In the meantime, as a workaround, you can update the values of the VisiblePeriodStart/VisiblePeriodEnd properties as well, when changing the "intervaltype".

I have updated your Telerik points for bringing the problem to our attention. 

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 >>
0
Fredy
Top achievements
Rank 1
answered on 19 May 2012, 07:50 PM
I have the same problem!

Do not
 have a workaround for now?

Please
 let me know when it is finally resolved. 

Thanks!.
0
Tsvetie
Telerik team
answered on 24 May 2012, 11:12 AM
Hi Fredy,

I have provided a workaround for the problem in my previous post. Additionally, in case you download the latest internal build, and test your application with it, the problem should be fixed. The fix will also be part of the next official release, which is scheduled for the beginning of June.

Greetings,
Tsvetie
the Telerik team

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

0
Michele
Top achievements
Rank 2
answered on 05 Jun 2012, 10:39 AM
excuse me has this problem been fixed with latest internal build? I think I've got the same problem in a MVVM pattern when changing a RadGridView selected item...
Thanks
0
Tsvetie
Telerik team
answered on 06 Jun 2012, 12:42 PM
Hi Paolo,

The problem, described in the original post in this forum thread was fixed in the latest internal build, as already mentioned. In case you still have problems using RadTimeBar with RadSparkline, please open a formal support ticket and send us detailed information on the problem that you have, together with a simple running project, demonstrating the problem itself.

Kind regards,
Tsvetie
the Telerik team

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

Tags
TimeBar
Asked by
Rob
Top achievements
Rank 1
Answers by
Rob
Top achievements
Rank 1
Tsvetie
Telerik team
Fredy
Top achievements
Rank 1
Michele
Top achievements
Rank 2
Share this question
or