or
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"
);
}
}
<
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
>
<
Window.Resources
>
<
DataTemplate
x:Key
=
"SubItemTemplate"
>
<
Grid
>
<
Grid.ColumnDefinitions
>
<
ColumnDefinition
Width
=
"40*"
/>
<
ColumnDefinition
Width
=
"60*"
/>
</
Grid.ColumnDefinitions
>
<
Image
Margin
=
"0"
Grid.Column
=
"0"
x:Name
=
"PartImageName"
Stretch
=
"Uniform"
/>
<
TextBlock
Grid.Column
=
"1"
Text
=
"Part ID"
x:Name
=
"PartID"
/>
</
Grid
>
</
DataTemplate
>
</
Window.Resources
>
<
telerik:RadDiagram
Margin
=
"2,2,2,2"
x:Name
=
"stateDiagram"
>
</
telerik:RadDiagram
>
private void Window_Loaded(object sender, RoutedEventArgs e)
{
RadDiagramShape StateBox = new RadDiagramShape()
{
Width = 100,
Height = 100,
Geometry = ShapeFactory.GetShapeGeometry(CommonShapeType.RectangleShape),
ContentTemplate = (DataTemplate)this.FindResource("SubItemTemplate"),
};
//now change dynamically the picture and the text of the StateBox:
ContentPresenter myContentPresenter = FindVisualChild<
ContentPresenter
>(StateBox,0);
Image imageInTemplate = (Image)Box.ContentTemplate.FindName("PartImageName", myContentPresenter);
imageInTemplate.Source = new Uri(strFilePath, UriKind.Absolute);
TextBlock textBlockInTemplate = (TextBlock)Box.ContentTemplate.FindName("PartID", myContentPresenter);
textBlockInTemplate.Text = "some part id";
stateDiagram.AddShape(StateBox);
}
Thank you very much.
Mikhail.