Hi Progress,
I was wondering if it is possible to combine BaseLine_WPF project and ProjectDeadline_WPF project inside your xaml-sdk-master samples/Examples?
If I have understood this correctly, TimelineContainerSelector in Xaml can only have one child. How can I give several behaviors to TimelineContainerSelector?
Thanx
Best Regards
kourosh
4 Answers, 1 is accepted
You can have only a single timeline container selector, but you can return different container types based on a condition. For example:
public
class
TimeLineCustomContainerSelector : DefaultTimeLineContainerSelector
{
protected
static
readonly
ContainerTypeIdentifier BaselineContainerType = ContainerTypeIdentifier.FromType<BaselineContainer>();
private
static
readonly
ContainerTypeIdentifier DeadlineEventInfoContainerType = ContainerTypeIdentifier.FromType<TimeLineDeadlineContainer>();
public
override
ContainerTypeIdentifier GetContainerType(
object
item)
{
if
(item
is
BaselineEventInfo)
{
return
BaselineContainerType;
}
else
if
(item
is
TimeLineDeadlineEventInfo)
{
return
DeadlineEventInfoContainerType;
}
return
base
.GetContainerType(item);
}
}
Regards,
Martin Ivanov
Progress Telerik

Hi Martin,
Thank you for your reply.
It seems to me that there are parts missing!
What about the behavior? How should TimeLineBaselineBehavior look like? I mean the behavior part is also different in projectdeadline and baseline samples:
<telerik:RadGanttView x:Name="GanttView"
TasksSource="{Binding Tasks}"
SelectedItem="{Binding SelectedTask, Mode=TwoWay}"
InitialExpandBehavior="Expanded"
Grid.Row="1"
VisibleRange="{Binding VisibleRange}"
TimeLineVisualizationBehavior="{Binding TimeLineBaselineBehavior}"
PixelLength="{Binding PixelLenght, Mode=TwoWay}"
>
Could you give me a whole working sample that shows how I can put ProjectDeadline sample and BaseLine sample in your sample package together? It would help a lot.
Best Regards
Kourosh

Hi Martin,
I got it! In case someone else needs it.
I put 2 behaviors together in a new file called TimeLineCustomBehavior like this:
public class TimeLineCustomBehavior : DefaultGanttTimeLineVisualizationBehavior
{
private DateTime projectDeadline;
public DateTime ProjectDeadline
{
get { return this.projectDeadline; }
set
{
if (this.projectDeadline != value)
{
this.projectDeadline = value;
this.OnPropertyChanged(string.Empty);
}
}
}
protected override IEnumerable GetBackgroundData(TimeLineVisualizationState state)
{
foreach (var background in base.GetBackgroundData(state))
{
yield return background;
}
var visibleRange = state.VisibleTimeRange;
var deadline = state.Rounder.Round(new DateRange(this.projectDeadline, this.projectDeadline));
var deadlineRange = new Range<long>(deadline.Start.Ticks, deadline.End.Ticks);
if (visibleRange.IntersectsWith(deadlineRange))
{
yield return new TimeLineDeadlineEventInfo(deadlineRange);
}
}
protected override IEnumerable<IEventInfo> GetEventInfos(TimeLineVisualizationState state, HierarchicalItem hierarchicalItem)
{
foreach (var eventInfo in base.GetEventInfos(state, hierarchicalItem))
{
yield return eventInfo;
}
var task = hierarchicalItem.SourceItem as CustomGanttTask;
var baselineStartDate = task != null ? task.StartPlannedDate : DateTime.MinValue;
if (baselineStartDate != null && baselineStartDate != DateTime.MinValue)
{
var roundedDeadline = state.Rounder.Round(new DateRange(baselineStartDate, task.EndPlannedDate));
var baselineRange = new Range<long>(roundedDeadline.Start.Ticks, roundedDeadline.End.Ticks);
if (baselineRange.IntersectsWith(state.VisibleTimeRange))
{
yield return new BaselineEventInfo(baselineRange, hierarchicalItem.Index, hierarchicalItem.SourceItem as CustomGanttTask);
}
}
}
}
and then in ViewModel initiated it:
private ITimeLineVisualizationBehavior timeLineCustomBehavior;
public ITimeLineVisualizationBehavior TimeLineCustomBehavior
{
get
{
return timeLineCustomBehavior;
}
set
{
timeLineCustomBehavior = value;
OnPropertyChanged(() => this.timeLineCustomBehavior);
}
}
inside the constructor:
this.timeLineCustomBehavior = new TimeLineCustomBehavior();
and in Example.xaml:
<telerik:RadGanttView x:Name="GanttView"
TasksSource="{Binding Tasks}"
SelectedItem="{Binding SelectedTask, Mode=TwoWay}"
InitialExpandBehavior="Expanded"
Grid.Row="1"
VisibleRange="{Binding VisibleRange}"
TimeLineVisualizationBehavior="{Binding TimeLineCustomBehavior}"
PixelLength="{Binding PixelLenght, Mode=TwoWay}"
>
It works!
Please do comment Martin.
Best Regards
Kourosh
I am glad that you found a solution. And thank you for sharing it here.
Regards,
Martin Ivanov
Progress Telerik