This example demonstrates how to display information in a tree from a hierarchical data structure using HierarchicalDataTemplate.
Imports System
Imports System.Windows
Imports System.Windows.Data
Imports System.Windows.Markup
Namespace HierarchicalDataTemplateMode
Partial Public Class MainWindow
Inherits Window
Public Sub New()
InitializeComponent()
DataContext = New ViewModel()
End Sub
End Class
Public Class ProjectObjectToProgressConverter
Inherits MarkupExtension
Implements IValueConverter
Public Function Convert(ByVal value As Object, ByVal targetType As Type, ByVal parameter As Object, ByVal culture As System.Globalization.CultureInfo) As Object Implements IValueConverter.Convert
Dim po = TryCast(value, ProjectObject)
If po IsNot Nothing Then
Return po.Progress
End If
Return Binding.DoNothing
' return value;
End Function
Public Function ConvertBack(ByVal value As Object, ByVal targetType As Type, ByVal parameter As Object, ByVal culture As System.Globalization.CultureInfo) As Object Implements IValueConverter.ConvertBack
Return value
End Function
Public Overrides Function ProvideValue(ByVal serviceProvider As IServiceProvider) As Object
Return Me
End Function
End Class
Public Class ProjectStageToProgressConverter
Inherits MarkupExtension
Implements IValueConverter
Public Function Convert(ByVal value As Object, ByVal targetType As Type, ByVal parameter As Object, ByVal culture As System.Globalization.CultureInfo) As Object Implements IValueConverter.Convert
Dim ps = TryCast(value, ProjectObject)
If ps IsNot Nothing Then
Return ps.Progress
End If
Return Binding.DoNothing
' return value;
End Function
Public Function ConvertBack(ByVal value As Object, ByVal targetType As Type, ByVal parameter As Object, ByVal culture As System.Globalization.CultureInfo) As Object Implements IValueConverter.ConvertBack
Return value
End Function
Public Overrides Function ProvideValue(ByVal serviceProvider As IServiceProvider) As Object
Return Me
End Function
End Class
Public Class TaskToStartDateConverter
Inherits MarkupExtension
Implements IValueConverter
Public Function Convert(ByVal value As Object, ByVal targetType As Type, ByVal parameter As Object, ByVal culture As System.Globalization.CultureInfo) As Object Implements IValueConverter.Convert
Dim obj = TryCast(value, Task)
If obj IsNot Nothing Then
Return obj.StartDate
End If
Return Binding.DoNothing
' return value;
End Function
Public Function ConvertBack(ByVal value As Object, ByVal targetType As Type, ByVal parameter As Object, ByVal culture As System.Globalization.CultureInfo) As Object Implements IValueConverter.ConvertBack
Return value
End Function
Public Overrides Function ProvideValue(ByVal serviceProvider As IServiceProvider) As Object
Return Me
End Function
End Class
Public Class TaskToEndDateConverter
Inherits MarkupExtension
Implements IValueConverter
Public Function Convert(ByVal value As Object, ByVal targetType As Type, ByVal parameter As Object, ByVal culture As System.Globalization.CultureInfo) As Object Implements IValueConverter.Convert
Dim obj = TryCast(value, Task)
If obj IsNot Nothing Then
Return obj.EndDate
End If
Return Binding.DoNothing
' return value;
End Function
Public Function ConvertBack(ByVal value As Object, ByVal targetType As Type, ByVal parameter As Object, ByVal culture As System.Globalization.CultureInfo) As Object Implements IValueConverter.ConvertBack
Return value
End Function
Public Overrides Function ProvideValue(ByVal serviceProvider As IServiceProvider) As Object
Return Me
End Function
End Class
Public Class TaskToStateConverter
Inherits MarkupExtension
Implements IValueConverter
Public Function Convert(ByVal value As Object, ByVal targetType As Type, ByVal parameter As Object, ByVal culture As System.Globalization.CultureInfo) As Object Implements IValueConverter.Convert
Dim obj = TryCast(value, Task)
If obj IsNot Nothing Then
Return obj.State
End If
Return Binding.DoNothing
' return value;
End Function
Public Function ConvertBack(ByVal value As Object, ByVal targetType As Type, ByVal parameter As Object, ByVal culture As System.Globalization.CultureInfo) As Object Implements IValueConverter.ConvertBack
Return value
End Function
Public Overrides Function ProvideValue(ByVal serviceProvider As IServiceProvider) As Object
Return Me
End Function
End Class
End Namespace
<Window x:Class="HierarchicalDataTemplateMode.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:dx="http://schemas.devexpress.com/winfx/2008/xaml/core"
xmlns:dxg="http://schemas.devexpress.com/winfx/2008/xaml/grid"
xmlns:dxe="http://schemas.devexpress.com/winfx/2008/xaml/editors"
xmlns:local="clr-namespace:HierarchicalDataTemplateMode"
Title="MainWindow" Height="450" Width="700">
<Window.Resources>
<ResourceDictionary>
<local:States x:Key="states" />
<HierarchicalDataTemplate DataType="{x:Type local:ProjectObject}" ItemsSource="{Binding Stages}">
<dx:MeasurePixelSnapper>
<StackPanel Orientation="Vertical">
<ContentPresenter x:Name="defaultRowPresenter" Content="{Binding}" ContentTemplate="{Binding View.DefaultDataRowTemplate}" />
<Border Padding="2" HorizontalAlignment="Stretch" VerticalAlignment="Center" BorderBrush="#FFC3CEDC" BorderThickness="0,1,0,0">
<ProgressBar Height="5" Minimum="0" Maximum="100" Value="{Binding Row,Converter={local:ProjectObjectToProgressConverter}}" />
</Border>
</StackPanel>
</dx:MeasurePixelSnapper>
</HierarchicalDataTemplate>
<HierarchicalDataTemplate DataType="{x:Type local:ProjectStage}" ItemsSource="{Binding Tasks}">
<dx:MeasurePixelSnapper>
<StackPanel Orientation="Vertical">
<ContentPresenter x:Name="defaultRowPresenter" Content="{Binding}" ContentTemplate="{Binding View.DefaultDataRowTemplate}" />
<Border Padding="2" HorizontalAlignment="Stretch" VerticalAlignment="Center" BorderBrush="#FFC3CEDC" BorderThickness="0,1,0,0">
<ProgressBar Height="5" Minimum="0" Maximum="100" Value="{Binding Row,Converter={local:ProjectStageToProgressConverter}}" />
</Border>
</StackPanel>
</dx:MeasurePixelSnapper>
</HierarchicalDataTemplate>
<ControlTemplate x:Key="ComboBoxStateItemTemplate">
<StackPanel Orientation="Horizontal" Margin="3,0,0,0" Background="Transparent">
<dx:PixelSnapper>
<Image Height="16" Width="16" Source="{Binding Path=(dxe:BaseEdit.OwnerEdit).SelectedItem.Image}" />
</dx:PixelSnapper>
<TextBlock Margin="2" Text="{Binding Path=(dxe:BaseEdit.OwnerEdit).SelectedItem.TextValue}" VerticalAlignment="Center" />
</StackPanel>
</ControlTemplate>
<DataTemplate DataType="{x:Type local:Task}">
<StackPanel Orientation="Vertical">
<dx:MeasurePixelSnapper>
<ContentPresenter x:Name="defaultRowPresenter" Content="{Binding}" ContentTemplate="{Binding View.DefaultDataRowTemplate}" />
</dx:MeasurePixelSnapper>
<Border Padding="2" HorizontalAlignment="Stretch" VerticalAlignment="Center" BorderBrush="#FFC3CEDC" BorderThickness="0,1,0,0">
<Grid HorizontalAlignment="Stretch" VerticalAlignment="Center">
<Grid.RowDefinitions>
<RowDefinition />
<RowDefinition />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<StackPanel Margin="2,0" Orientation="Horizontal" Grid.Column="0" Grid.Row="0">
<TextBlock Text="StartDate:" FontWeight="Bold" />
<TextBlock Text="{Binding Row, StringFormat='MM/dd/yyyy',Converter={local:TaskToStartDateConverter}}" Margin="3,0,0,0" />
</StackPanel>
<StackPanel Margin="2,0" Orientation="Horizontal" Grid.Column="0" Grid.Row="1">
<TextBlock Text="EndDate:" FontWeight="Bold" />
<TextBlock Text="{Binding Row, StringFormat='MM/dd/yyyy',Converter={local:TaskToEndDateConverter}}" Margin="3,0,0,0" />
</StackPanel>
<dxe:ComboBoxEdit HorizontalAlignment="Right" VerticalAlignment="Center" MinWidth="100" Foreground="Black" IsTextEditable="False"
ItemsSource="{Binding DataSource, Source={StaticResource states}}"
DisplayTemplate="{StaticResource ComboBoxStateItemTemplate}"
EditNonEditableTemplate="{StaticResource ComboBoxStateItemTemplate}"
SelectedItem="{Binding Row, Mode=TwoWay,Converter={local:TaskToStateConverter}}"
Grid.Column="1" Grid.RowSpan="2">
<dxe:ComboBoxEdit.ItemTemplate>
<DataTemplate>
<StackPanel Orientation="Horizontal">
<dx:MeasurePixelSnapper SnapperType="Around">
<Image Height="16" Width="16" Source="{Binding Image}" />
</dx:MeasurePixelSnapper>
<TextBlock Text="{Binding TextValue}" Margin="2" />
</StackPanel>
</DataTemplate>
</dxe:ComboBoxEdit.ItemTemplate>
</dxe:ComboBoxEdit>
</Grid>
</Border>
</StackPanel>
</DataTemplate>
</ResourceDictionary>
</Window.Resources>
<Grid>
<dxg:TreeListControl x:Name="treeList" ItemsSource="{Binding DataItems}" >
<dxg:TreeListControl.Columns>
<dxg:TreeListColumn FieldName="Name" AllowSorting="True" />
<dxg:TreeListColumn FieldName="Executor" AllowSorting="True" />
</dxg:TreeListControl.Columns>
<dxg:TreeListControl.View>
<dxg:TreeListView x:Name="view" TreeDerivationMode="HierarchicalDataTemplate"
AllowEditing="True" NavigationStyle="Cell" />
</dxg:TreeListControl.View>
</dxg:TreeListControl>
</Grid>
</Window>
<Application x:Class="HierarchicalDataBinding.App"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
StartupUri="MainWindow.xaml">
<Application.Resources>
</Application.Resources>
</Application>
Imports System
Imports System.Collections.Generic
Imports System.Configuration
Imports System.Data
Imports System.Linq
Imports System.Windows
Namespace HierarchicalDataBinding
''' <summary>
''' Interaction logic for App.xaml
''' </summary>
Partial Public Class App
Inherits Application
End Class
End Namespace
Imports System
Imports System.Collections.ObjectModel
Imports System.Collections
Imports DevExpress.Xpf.Grid
Imports System.Windows.Data
Imports System.Windows.Media
Namespace HierarchicalDataTemplateMode
Public Class ViewModel
Public Property DataItems() As ObservableCollection(Of ProjectObject)
Public Sub New()
DataItems = InitData()
End Sub
Private Function InitData() As ObservableCollection(Of ProjectObject)
Dim projects As New ObservableCollection(Of ProjectObject)()
Dim betaronProject As New ProjectObject() With {.Name = "Project: Betaron"}
Dim stantoneProject As New ProjectObject() With {.Name = "Project: Stanton"}
InitBetaronProjectData(betaronProject)
InitStantoneProjectData(stantoneProject)
projects.Add(betaronProject)
projects.Add(stantoneProject)
Return projects
End Function
Private Sub InitBetaronProjectData(ByVal betaronProject As ProjectObject)
betaronProject.Executor = "Mcfadyen Ball"
Dim stage21 As New ProjectStage() With {.Name = "Information Gathering", .Executor = "Kaiden Savastano", .Owner = betaronProject}
stage21.Tasks.Add(New Task() With {.Name = "Market research", .Executor = "Carmine Then", .StartDate = New Date(2011, 10, 1), .EndDate = New Date(2011, 10, 5), .State = States.DataSource(2), .Owner = stage21})
stage21.Tasks.Add(New Task() With {.Name = "Making specification", .Executor = "Seto Kober", .StartDate = New Date(2011, 10, 5), .EndDate = New Date(2011, 10, 10), .State = States.DataSource(1), .Owner = stage21})
Dim stage22 As New ProjectStage() With {.Name = "Planning", .Executor = "Manley Difrancesco", .Owner = betaronProject}
stage22.Tasks.Add(New Task() With {.Name = "Documentation", .Executor = "Martez Gollin", .StartDate = New Date(2011, 10, 15), .EndDate = New Date(2011, 10, 16), .State = States.DataSource(0), .Owner = stage22})
Dim stage23 As New ProjectStage() With {.Name = "Design", .Executor = "Clint Mary", .Owner = betaronProject}
stage23.Tasks.Add(New Task() With {.Name = "Design of a web pages", .Executor = "Gasper Hartsell", .StartDate = New Date(2011, 10, 13), .EndDate = New Date(2011, 10, 14), .State = States.DataSource(0), .Owner = stage23})
stage23.Tasks.Add(New Task() With {.Name = "Pages layout", .Executor = "Shirish Huminski", .StartDate = New Date(2011, 10, 13), .EndDate = New Date(2011, 10, 14), .State = States.DataSource(0), .Owner = stage23})
Dim stage24 As New ProjectStage() With {.Name = "Development", .Executor = "Edwin Thone", .Owner = betaronProject}
stage24.Tasks.Add(New Task() With {.Name = "Design", .Executor = "Zarko Knill", .StartDate = New Date(2011, 10, 27), .EndDate = New Date(2011, 10, 28), .State = States.DataSource(0), .Owner = stage24})
stage24.Tasks.Add(New Task() With {.Name = "Coding", .Executor = "Harley Kirckof", .StartDate = New Date(2011, 10, 29), .EndDate = New Date(2011, 10, 30), .State = States.DataSource(0), .Owner = stage24})
Dim stage25 As New ProjectStage() With {.Name = "Testing and Delivery", .Executor = "Boucher Hislop", .Owner = betaronProject}
stage25.Tasks.Add(New Task() With {.Name = "Testing", .Executor = "Sarah Ragas", .StartDate = New Date(2011, 10, 13), .EndDate = New Date(2011, 10, 14), .State = States.DataSource(0), .Owner = stage25})
stage25.Tasks.Add(New Task() With {.Name = "Content", .Executor = "Rashid Terinoni", .StartDate = New Date(2011, 10, 13), .EndDate = New Date(2011, 10, 14), .State = States.DataSource(0), .Owner = stage25})
betaronProject.Stages.Add(stage21)
betaronProject.Stages.Add(stage22)
betaronProject.Stages.Add(stage23)
betaronProject.Stages.Add(stage24)
betaronProject.Stages.Add(stage25)
End Sub
Private Sub InitStantoneProjectData(ByVal stantoneProject As ProjectObject)
stantoneProject.Executor = "Ruben Ackerman"
Dim stage11 As New ProjectStage() With {.Name = "Information Gathering", .Executor = "Huyen Trinklein", .Owner = stantoneProject}
stage11.Tasks.Add(New Task() With {.Name = "Market research", .Executor = "Tanner Crittendon", .StartDate = New Date(2011, 10, 1), .EndDate = New Date(2011, 10, 5), .State = States.DataSource(2), .Owner = stage11})
stage11.Tasks.Add(New Task() With {.Name = "Making specification", .Executor = "Carmine Then", .StartDate = New Date(2011, 10, 5), .EndDate = New Date(2011, 10, 10), .State = States.DataSource(2), .Owner = stage11})
Dim stage12 As New ProjectStage() With {.Name = "Planning", .Executor = "Alfredo Sookoo", .Owner = stantoneProject}
stage12.Tasks.Add(New Task() With {.Name = "Documentation", .Executor = "Gorf Wobbe", .StartDate = New Date(2011, 10, 13), .EndDate = New Date(2011, 10, 14), .State = States.DataSource(2), .Owner = stage12})
Dim stage13 As New ProjectStage() With {.Name = "Design", .Executor = "Saphire Plump", .Owner = stantoneProject}
stage13.Tasks.Add(New Task() With {.Name = "Design of a web pages", .Executor = "Dominic Minden", .StartDate = New Date(2011, 10, 13), .EndDate = New Date(2011, 10, 14), .State = States.DataSource(1), .Owner = stage13})
stage13.Tasks.Add(New Task() With {.Name = "Pages layout", .Executor = "Pinkerton Trezise", .StartDate = New Date(2011, 10, 13), .EndDate = New Date(2011, 10, 14), .State = States.DataSource(1), .Owner = stage13})
Dim stage14 As New ProjectStage() With {.Name = "Development", .Executor = "Lauren Partain", .Owner = stantoneProject}
stage14.Tasks.Add(New Task() With {.Name = "Design", .Executor = "Delilah Beamer", .StartDate = New Date(2011, 10, 23), .EndDate = New Date(2011, 10, 24), .State = States.DataSource(1), .Owner = stage14})
stage14.Tasks.Add(New Task() With {.Name = "Coding", .Executor = "Dunaway Dupriest", .StartDate = New Date(2011, 10, 25), .EndDate = New Date(2011, 10, 26), .State = States.DataSource(0), .Owner = stage14})
Dim stage15 As New ProjectStage() With {.Name = "Testing and Delivery", .Executor = "Christos Arrant", .Owner = stantoneProject}
stage15.Tasks.Add(New Task() With {.Name = "Testing", .Executor = "Grice Ohora", .StartDate = New Date(2011, 10, 13), .EndDate = New Date(2011, 10, 14), .State = States.DataSource(0), .Owner = stage15})
stage15.Tasks.Add(New Task() With {.Name = "Content", .Executor = "Christos Arrant", .StartDate = New Date(2011, 10, 13), .EndDate = New Date(2011, 10, 14), .State = States.DataSource(0), .Owner = stage15})
stantoneProject.Stages.Add(stage11)
stantoneProject.Stages.Add(stage12)
stantoneProject.Stages.Add(stage13)
stantoneProject.Stages.Add(stage14)
stantoneProject.Stages.Add(stage15)
End Sub
End Class
End Namespace
using System;
using System.Collections.ObjectModel;
using System.Collections;
using DevExpress.Xpf.Grid;
using System.Windows.Data;
using System.Windows.Media;
namespace HierarchicalDataTemplateMode {
public class ViewModel {
public ObservableCollection<ProjectObject> DataItems { get; set; }
public ViewModel() {
DataItems = InitData();
}
private ObservableCollection<ProjectObject> InitData() {
ObservableCollection<ProjectObject> projects = new ObservableCollection<ProjectObject>();
ProjectObject betaronProject = new ProjectObject() { Name = "Project: Betaron" };
ProjectObject stantoneProject = new ProjectObject() { Name = "Project: Stanton" };
InitBetaronProjectData(betaronProject);
InitStantoneProjectData(stantoneProject);
projects.Add(betaronProject);
projects.Add(stantoneProject);
return projects;
}
void InitBetaronProjectData(ProjectObject betaronProject) {
betaronProject.Executor = "Mcfadyen Ball";
ProjectStage stage21 = new ProjectStage() { Name = "Information Gathering", Executor = "Kaiden Savastano", Owner = betaronProject };
stage21.Tasks.Add(new Task() { Name = "Market research", Executor = "Carmine Then", StartDate = new DateTime(2011, 10, 1), EndDate = new DateTime(2011, 10, 5), State = States.DataSource[2], Owner = stage21 });
stage21.Tasks.Add(new Task() { Name = "Making specification", Executor = "Seto Kober", StartDate = new DateTime(2011, 10, 5), EndDate = new DateTime(2011, 10, 10), State = States.DataSource[1], Owner = stage21 });
ProjectStage stage22 = new ProjectStage() { Name = "Planning", Executor = "Manley Difrancesco", Owner = betaronProject };
stage22.Tasks.Add(new Task() { Name = "Documentation", Executor = "Martez Gollin", StartDate = new DateTime(2011, 10, 15), EndDate = new DateTime(2011, 10, 16), State = States.DataSource[0], Owner = stage22 });
ProjectStage stage23 = new ProjectStage() { Name = "Design", Executor = "Clint Mary", Owner = betaronProject };
stage23.Tasks.Add(new Task() { Name = "Design of a web pages", Executor = "Gasper Hartsell", StartDate = new DateTime(2011, 10, 13), EndDate = new DateTime(2011, 10, 14), State = States.DataSource[0], Owner = stage23 });
stage23.Tasks.Add(new Task() { Name = "Pages layout", Executor = "Shirish Huminski", StartDate = new DateTime(2011, 10, 13), EndDate = new DateTime(2011, 10, 14), State = States.DataSource[0], Owner = stage23 });
ProjectStage stage24 = new ProjectStage() { Name = "Development", Executor = "Edwin Thone", Owner = betaronProject };
stage24.Tasks.Add(new Task() { Name = "Design", Executor = "Zarko Knill", StartDate = new DateTime(2011, 10, 27), EndDate = new DateTime(2011, 10, 28), State = States.DataSource[0], Owner = stage24 });
stage24.Tasks.Add(new Task() { Name = "Coding", Executor = "Harley Kirckof", StartDate = new DateTime(2011, 10, 29), EndDate = new DateTime(2011, 10, 30), State = States.DataSource[0], Owner = stage24 });
ProjectStage stage25 = new ProjectStage() { Name = "Testing and Delivery", Executor = "Boucher Hislop", Owner = betaronProject };
stage25.Tasks.Add(new Task() { Name = "Testing", Executor = "Sarah Ragas", StartDate = new DateTime(2011, 10, 13), EndDate = new DateTime(2011, 10, 14), State = States.DataSource[0], Owner = stage25 });
stage25.Tasks.Add(new Task() { Name = "Content", Executor = "Rashid Terinoni", StartDate = new DateTime(2011, 10, 13), EndDate = new DateTime(2011, 10, 14), State = States.DataSource[0], Owner = stage25 });
betaronProject.Stages.Add(stage21);
betaronProject.Stages.Add(stage22);
betaronProject.Stages.Add(stage23);
betaronProject.Stages.Add(stage24);
betaronProject.Stages.Add(stage25);
}
void InitStantoneProjectData(ProjectObject stantoneProject) {
stantoneProject.Executor = "Ruben Ackerman";
ProjectStage stage11 = new ProjectStage() { Name = "Information Gathering", Executor = "Huyen Trinklein", Owner = stantoneProject };
stage11.Tasks.Add(new Task() { Name = "Market research", Executor = "Tanner Crittendon", StartDate = new DateTime(2011, 10, 1), EndDate = new DateTime(2011, 10, 5), State = States.DataSource[2], Owner = stage11 });
stage11.Tasks.Add(new Task() { Name = "Making specification", Executor = "Carmine Then", StartDate = new DateTime(2011, 10, 5), EndDate = new DateTime(2011, 10, 10), State = States.DataSource[2], Owner = stage11 });
ProjectStage stage12 = new ProjectStage() { Name = "Planning", Executor = "Alfredo Sookoo", Owner = stantoneProject };
stage12.Tasks.Add(new Task() { Name = "Documentation", Executor = "Gorf Wobbe", StartDate = new DateTime(2011, 10, 13), EndDate = new DateTime(2011, 10, 14), State = States.DataSource[2], Owner = stage12 });
ProjectStage stage13 = new ProjectStage() { Name = "Design", Executor = "Saphire Plump", Owner = stantoneProject };
stage13.Tasks.Add(new Task() { Name = "Design of a web pages", Executor = "Dominic Minden", StartDate = new DateTime(2011, 10, 13), EndDate = new DateTime(2011, 10, 14), State = States.DataSource[1], Owner = stage13 });
stage13.Tasks.Add(new Task() { Name = "Pages layout", Executor = "Pinkerton Trezise", StartDate = new DateTime(2011, 10, 13), EndDate = new DateTime(2011, 10, 14), State = States.DataSource[1], Owner = stage13 });
ProjectStage stage14 = new ProjectStage() { Name = "Development", Executor = "Lauren Partain", Owner = stantoneProject };
stage14.Tasks.Add(new Task() { Name = "Design", Executor = "Delilah Beamer", StartDate = new DateTime(2011, 10, 23), EndDate = new DateTime(2011, 10, 24), State = States.DataSource[1], Owner = stage14 });
stage14.Tasks.Add(new Task() { Name = "Coding", Executor = "Dunaway Dupriest", StartDate = new DateTime(2011, 10, 25), EndDate = new DateTime(2011, 10, 26), State = States.DataSource[0], Owner = stage14 });
ProjectStage stage15 = new ProjectStage() { Name = "Testing and Delivery", Executor = "Christos Arrant", Owner = stantoneProject };
stage15.Tasks.Add(new Task() { Name = "Testing", Executor = "Grice Ohora", StartDate = new DateTime(2011, 10, 13), EndDate = new DateTime(2011, 10, 14), State = States.DataSource[0], Owner = stage15 });
stage15.Tasks.Add(new Task() { Name = "Content", Executor = "Christos Arrant", StartDate = new DateTime(2011, 10, 13), EndDate = new DateTime(2011, 10, 14), State = States.DataSource[0], Owner = stage15 });
stantoneProject.Stages.Add(stage11);
stantoneProject.Stages.Add(stage12);
stantoneProject.Stages.Add(stage13);
stantoneProject.Stages.Add(stage14);
stantoneProject.Stages.Add(stage15);
}
}
}
using System;
using System.Windows;
using System.Windows.Data;
using System.Windows.Markup;
namespace HierarchicalDataTemplateMode {
public partial class MainWindow : Window {
public MainWindow() {
InitializeComponent();
DataContext = new ViewModel();
}
}
public class ProjectObjectToProgressConverter : MarkupExtension, IValueConverter {
public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) {
var po = value as ProjectObject;
if (po != null)
return po.Progress;
return Binding.DoNothing;
// return value;
}
public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) {
return value;
}
public override object ProvideValue(IServiceProvider serviceProvider) {
return this;
}
}
public class ProjectStageToProgressConverter : MarkupExtension, IValueConverter {
public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) {
var ps = value as ProjectObject;
if (ps != null)
return ps.Progress;
return Binding.DoNothing;
// return value;
}
public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) {
return value;
}
public override object ProvideValue(IServiceProvider serviceProvider) {
return this;
}
}
public class TaskToStartDateConverter : MarkupExtension, IValueConverter {
public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) {
var obj = value as Task;
if (obj != null)
return obj.StartDate;
return Binding.DoNothing;
// return value;
}
public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) {
return value;
}
public override object ProvideValue(IServiceProvider serviceProvider) {
return this;
}
}
public class TaskToEndDateConverter : MarkupExtension, IValueConverter {
public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) {
var obj = value as Task;
if (obj != null)
return obj.EndDate;
return Binding.DoNothing;
// return value;
}
public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) {
return value;
}
public override object ProvideValue(IServiceProvider serviceProvider) {
return this;
}
}
public class TaskToStateConverter : MarkupExtension, IValueConverter {
public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) {
var obj = value as Task;
if (obj != null)
return obj.State;
return Binding.DoNothing;
// return value;
}
public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) {
return value;
}
public override object ProvideValue(IServiceProvider serviceProvider) {
return this;
}
}
}