I want to bind the properties PeriodStart, PeriodEnd, VisiblePeriodStart, and VisiblePeriodEnd to my ViewModel, but it doesn't work like expected. Could this be a bug in the RadTimeline control?
My ViewModel class is called ParentViewModel:
I set an instance of this class as the DataContext of a RadTimeline, and bind the PeriodStart and PeriodEnd properties like this:
The Start and End properties are correctly bound to the TextBlocks and the Dates are displayed.
However, the RadTimeline's content is blank.
I tried to raise the OnPropertyChanged events (in the method FirePropertysChanged in my ViewModel), but that doesn't help.
When the date values are hardcoded in XAML, the RadTimeline works. But it doesn't work if bound to a ViewModel.
Could this be a bug?
My ViewModel class is called ParentViewModel:
public
class
ParentViewModel : ViewModelBase
{
public
String Name {
get
;
set
; }
//public DateTime Start { get { return ChildItems.Min(x => x.Start); } }
//public DateTime End { get { return ChildItems.Max(x => x.End); } }
public
DateTime Start {
get
{
return
DateTime.Now; } }
public
DateTime End {
get
{
return
DateTime.Now.AddDays(7.0); } }
public
TimeSpan Duration {
get
{
return
End - Start; } }
public
ObservableCollection<TestViewModel> ChildItems {
get
;
private
set
; }
public
ParentViewModel()
{
ChildItems =
new
ObservableCollection<TestViewModel>();
}
public
void
AddChilds(IEnumerable<TestViewModel> childs)
{
foreach
(var x
in
childs)
{
ChildItems.Add(x);
}
}
public
void
FirePropertysChanged()
{
OnPropertyChanged(
"Start"
);
OnPropertyChanged(
"End"
);
}
}
I set an instance of this class as the DataContext of a RadTimeline, and bind the PeriodStart and PeriodEnd properties like this:
<
Grid
x:Name
=
"LayoutRoot"
>
<
Grid.RowDefinitions
>
<
RowDefinition
Height
=
"Auto"
/>
<
RowDefinition
Height
=
"Auto"
/>
<
RowDefinition
Height
=
"*"
/>
</
Grid.RowDefinitions
>
<
StackPanel
Orientation
=
"Horizontal"
Margin
=
"2"
>
<
TextBlock
FontWeight
=
"Bold"
Text
=
"PeriodStart: "
/>
<
TextBlock
Text
=
"{Binding Start}"
/>
</
StackPanel
>
<
StackPanel
Orientation
=
"Horizontal"
Grid.Row
=
"1"
Margin
=
"2"
>
<
TextBlock
FontWeight
=
"Bold"
Text
=
"PeriodEnd: "
/>
<
TextBlock
Text
=
"{Binding End}"
/>
</
StackPanel
>
<
telerik:RadTimeline
x:Name
=
"radTimeline1"
Grid.Row
=
"2"
PeriodStart
=
"{Binding Start}"
PeriodEnd
=
"{Binding End}"
StartPath
=
"Start"
DurationPath
=
"Duration"
ItemsSource
=
"{Binding ChildItems}"
>
<
telerik:RadTimeline.Intervals
>
<
telerik:MonthInterval
/>
<
telerik:WeekInterval
/>
<
telerik:DayInterval
/>
<
telerik:HourInterval
/>
<
telerik:MinuteInterval
/>
</
telerik:RadTimeline.Intervals
>
</
telerik:RadTimeline
>
</
Grid
>
The Start and End properties are correctly bound to the TextBlocks and the Dates are displayed.
However, the RadTimeline's content is blank.
I tried to raise the OnPropertyChanged events (in the method FirePropertysChanged in my ViewModel), but that doesn't help.
When the date values are hardcoded in XAML, the RadTimeline works. But it doesn't work if bound to a ViewModel.
Could this be a bug?