This question is locked. New answers and comments are not allowed.
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));
}
}
}
}