This question is locked. New answers and comments are not allowed.
Hi,
I am using Silverlight Telerik GanttChart. Can you please suggest me to add the dependency to the tasks and also need to Include the tick interval Daily, Monthly,weekly based on checkboxor button click event or dropdown change event.
Please refer my xaml and c# code as below:
XAML code:
C# code:
Regards,
Kannan S
I am using Silverlight Telerik GanttChart. Can you please suggest me to add the dependency to the tasks and also need to Include the tick interval Daily, Monthly,weekly based on checkboxor button click event or dropdown change event.
Please refer my xaml and c# code as below:
XAML code:
<
UserControl.Resources
>
<
ResourceDictionary
>
<
ResourceDictionary.MergedDictionaries
>
<
ResourceDictionary
Source
=
"/Telerik.Windows.Themes.Metro;component/Themes/System.Windows.xaml"
/>
<
ResourceDictionary
Source
=
"/Telerik.Windows.Themes.Metro;component/Themes/Telerik.Windows.Controls.xaml"
/>
<
ResourceDictionary
Source
=
"/Telerik.Windows.Themes.Metro;component/Themes/Telerik.Windows.Controls.GanttView.xaml"
/>
</
ResourceDictionary.MergedDictionaries
>
</
ResourceDictionary
>
</
UserControl.Resources
>
<
Grid
x:Name
=
"LayoutRoot"
Background
=
"White"
>
<!--<telerik:RadGanttView Name="xGanttView" HorizontalAlignment="Left" Margin="18,1,0,0" VerticalAlignment="Top" Width="Auto" />-->
<
telerik:RadGanttView
x:Name
=
"ganttview"
BorderBrush
=
"#FFD6D4D4"
Width
=
"1000"
BorderThickness
=
"1 0 1 1"
Grid.Row
=
"1"
Margin
=
"0 6 0 0"
>
<
telerik:RadGanttView.Columns
>
<
telerik:TreeColumnDefinition
>
<
telerik:TreeColumnDefinition.CellTemplate
>
<
DataTemplate
>
</
DataTemplate
>
</
telerik:TreeColumnDefinition.CellTemplate
>
</
telerik:TreeColumnDefinition
>
<
telerik:ColumnDefinition
MemberBinding
=
"{Binding Title}"
Header
=
"Activities"
ColumnWidth
=
"160"
>
</
telerik:ColumnDefinition
>
<
telerik:ColumnDefinition
MemberBinding
=
"{Binding Start}"
Header
=
"Start"
ColumnWidth
=
"120"
>
</
telerik:ColumnDefinition
>
<
telerik:ColumnDefinition
MemberBinding
=
"{Binding End}"
Header
=
"End"
ColumnWidth
=
"120"
>
</
telerik:ColumnDefinition
>
<
telerik:ColumnDefinition
MemberBinding
=
"{Binding Duration}"
Header
=
"Duration"
ColumnWidth
=
"100"
>
</
telerik:ColumnDefinition
>
<
telerik:ColumnDefinition
MemberBinding
=
"{Binding Progress}"
Header
=
"Progress"
ColumnWidth
=
"100"
>
</
telerik:ColumnDefinition
>
<!--<telerik:ColumnDefinition MemberBinding="{Binding IsMilestone}" Header="IsMilestone" ColumnWidth="100" />-->
</
telerik:RadGanttView.Columns
>
</
telerik:RadGanttView
>
</
Grid
>
</
UserControl
>
using
System;
using
System.Collections.Generic;
using
System.Linq;
using
System.Net;
using
System.Windows;
using
System.Windows.Controls;
using
System.Windows.Documents;
using
System.Windows.Input;
using
System.Windows.Media;
using
System.Windows.Media.Animation;
using
System.Windows.Shapes;
using
Telerik.Windows.Controls.GanttView;
using
Telerik.Windows.Controls.Scheduling;
using
Telerik.Windows.Core;
using
System.Collections.ObjectModel;
using
SLGanttChart.WcfRef;
using
Telerik.Windows.Controls;
namespace
SLGanttChart
{
public
partial
class
MainPage : UserControl
{
public
static
Collection<WcfRef.ProjectPlan_BO> lstProjectPlan;
private
IRangeGenerator specialSlotsGenerator;
public
static
Collection<ProjectPlan> lstProject;
private
readonly
static
Dictionary<
string
, Tuple<GanttTask,
string
>> taskIdToGanttTask =
new
Dictionary<
string
, Tuple<GanttTask,
string
>>();
private
readonly
static
Dictionary<
string
, IList<
string
>> taskToChildren =
new
Dictionary<
string
, IList<
string
>>();
private
readonly
static
Dictionary<
string
, IList<
string
>> taskToRelation =
new
Dictionary<
string
, IList<
string
>>();
public
MainPage()
{
InitializeComponent();
Random rnd =
new
Random();
this
.Loaded +=
new
RoutedEventHandler(MainPage_Loaded);
}
void
MainPage_Loaded(
object
sender, RoutedEventArgs e)
{
LoadSampleChart();
}
private
void
LoadSampleChart()
{
lstProject =
new
Collection<ProjectPlan>();
ProjectPlan lstPrj =
new
ProjectPlan();
lstPrj.Title =
"ProjectABC"
;
lstPrj.Start = Convert.ToDateTime(
"01/12/2012"
);
lstPrj.End = Convert.ToDateTime(
"10/01/2012"
);
lstPrj.IsDependency =
false
;
lstPrj.IsMilestone =
false
;
lstPrj.Duration = lstPrj.End.Subtract(lstPrj.Start);
lstProject.Add(lstPrj);
ProjectPlan lstPrj1 =
new
ProjectPlan();
lstPrj1.Title =
"Code Drop"
;
lstPrj1.Start = Convert.ToDateTime(
"07/12/2012"
);
lstPrj1.End = Convert.ToDateTime(
"07/12/2012"
);
lstPrj1.IsDependency =
true
;
lstPrj1.IsMilestone =
false
;
lstPrj1.Duration = lstPrj1.End.Subtract(lstPrj1.Start);
lstProject.Add(lstPrj1);
ProjectPlan lstPrj2 =
new
ProjectPlan();
lstPrj2.Title =
"ST Cycle1"
;
lstPrj2.Start = Convert.ToDateTime(
"07/13/2012"
);
lstPrj2.End = Convert.ToDateTime(
"08/31/2012"
);
lstPrj2.IsDependency =
false
;
lstPrj2.IsMilestone =
false
;
lstPrj2.Duration = lstPrj2.End.Subtract(lstPrj2.Start);
lstProject.Add(lstPrj2);
ProjectPlan lstPrj3 =
new
ProjectPlan();
lstPrj3.Title =
"ST Cycle2"
;
lstPrj3.Start = Convert.ToDateTime(
"09/03/2012"
);
lstPrj3.End = Convert.ToDateTime(
"09/29/2012"
);
lstPrj3.IsDependency =
false
;
lstPrj3.IsMilestone =
false
;
lstPrj3.Duration = lstPrj3.End.Subtract(lstPrj3.Start);
lstProject.Add(lstPrj3);
ProjectPlan lstPrj4 =
new
ProjectPlan();
lstPrj4.Title =
"ETOR Report"
;
lstPrj4.Start = Convert.ToDateTime(
"10/01/2012"
);
lstPrj4.End = Convert.ToDateTime(
"10/20/2012"
);
lstPrj4.IsDependency =
false
;
lstPrj4.IsMilestone =
true
;
lstPrj4.Duration = lstPrj4.End.Subtract(lstPrj4.Start);
lstProject.Add(lstPrj4);
DateTime dtMax = (from lst
in
lstProject select lst.Start).Max();
DateTime dtMin = (from lst
in
lstProject select lst.End).Min();
var d = dtMax;
ganttview.VisibleRange =
new
VisibleRange(dtMin, dtMax);
var tasks =
new
ObservableCollection<GanttTask>();
var gt =
new
GanttTask();
gt.UniqueId =
"0"
;
gt.Title = lstPrj.Title;
gt.Start = dtMin;
gt.End = dtMax;
gt.Duration = dtMax.Subtract(dtMin);
var childGT =
new
GanttTask();
childGT.UniqueId =
"1"
;
childGT.Start = lstPrj1.Start;
childGT.End = lstPrj1.End;
childGT.Title = lstPrj1.Title;
childGT.Duration = lstPrj1.End.Subtract(lstPrj1.Start);
childGT.IsMilestone = lstPrj1.IsMilestone;
var childGT1 =
new
GanttTask();
childGT1.UniqueId =
"1"
;
childGT1.Start = lstPrj2.Start;
childGT1.End = lstPrj2.End;
childGT1.Title = lstPrj2.Title;
childGT1.Duration = lstPrj2.End.Subtract(lstPrj2.Start);
childGT1.IsMilestone = lstPrj2.IsMilestone;
childGT.Children.Add(childGT1);
gt.Children.Add(childGT);
tasks.Add(gt);
ganttview.TasksSource = tasks;
}
}
public
class
ProjectPlan
{
public
string
Title{
get
;
set
;}
public
DateTime Start {
get
;
set
;}
public
DateTime End {
get
;
set
; }
public
double
Progress {
get
;
set
; }
public
TimeSpan Duration {
get
;
set
; }
public
string
ExecutableFlag {
get
;
set
; }
public
Boolean IsMilestone {
get
;
set
; }
public
Boolean IsDependency {
get
;
set
; }
}
}
Regards,
Kannan S