-
Notifications
You must be signed in to change notification settings - Fork 0
/
MainWindow.xaml
94 lines (91 loc) · 4.29 KB
/
MainWindow.xaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
<Window
x:Class="DiagramNestedItemsExample.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:dxdiag="http://schemas.devexpress.com/winfx/2008/xaml/diagram"
xmlns:dxmvvm="http://schemas.devexpress.com/winfx/2008/xaml/mvvm"
xmlns:local="clr-namespace:DiagramNestedItemsExample"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
Title="MainWindow"
Width="1000"
Height="900"
mc:Ignorable="d">
<Window.DataContext>
<local:ViewModel />
</Window.DataContext>
<Window.Resources>
<local:KeySelector x:Key="keySelector" />
<local:ItemsSelector x:Key="itemsSelector"/>
<local:DiagramItemTemplateSelector x:Key="diagramItemTemplateSelector">
<local:DiagramItemTemplateSelector.DepartmentTemplate>
<DataTemplate>
<dxdiag:DiagramList
MinWidth="240"
CanAddItems="False"
CanAttachConnectorBeginPoint="False"
CanAttachConnectorEndPoint="False"
CanCollapse="True"
DragMode="ByAnyPoint"
Header="{Binding DepartmentName}"
ItemsCanMove="False"
ItemsCanSelect="True"
ShowHeader="True" />
</DataTemplate>
</local:DiagramItemTemplateSelector.DepartmentTemplate>
<local:DiagramItemTemplateSelector.SectionTemplate>
<DataTemplate>
<dxdiag:DiagramList
Orientation="Horizontal"
CanAttachConnectorBeginPoint="False"
CanAttachConnectorEndPoint="False"
CanCollapse="False"
DragMode="ByAnyPoint"
Header="{Binding SectionName}"
ItemsCanMove="False"
ItemsCanSelect="True"
ShowHeader="True" />
</DataTemplate>
</local:DiagramItemTemplateSelector.SectionTemplate>
<local:DiagramItemTemplateSelector.EmployeeTemplate>
<DataTemplate>
<dxdiag:DiagramShape
MinHeight="50"
Background="Green"
ConnectionPoints="0,0.5 1,0.5"
Content="{Binding EmployeeName}" />
</DataTemplate>
</local:DiagramItemTemplateSelector.EmployeeTemplate>
</local:DiagramItemTemplateSelector>
<DataTemplate x:Key="connectorTemplate">
<dxdiag:DiagramConnector
BeginPointRestrictions="KeepConnected"
CanEdit="False"
EndPointRestrictions="KeepConnected" />
</DataTemplate>
</Window.Resources>
<Grid>
<dxdiag:DiagramDesignerControl
x:Name="diagramControl1"
ConnectorsSeparationMode="AllLines"
SelectedStencils="BasicShapes, BasicFlowchartShapes"
SugiyamaLayoutColumnSpacing="300"
SugiyamaLayoutDirection="LeftToRight"
SugiyamaLayoutLayerSpacing="400"
SugiyamaLayoutLayersAlignment="Center">
<dxmvvm:Interaction.Behaviors>
<dxdiag:DiagramDataBindingBehavior
ConnectorFromMember="FromEmployeeID"
ConnectorTemplate="{StaticResource connectorTemplate}"
ConnectorToMember="ToEmployeeID"
ConnectorsSource="{Binding Relations}"
ItemTemplateSelector="{StaticResource diagramItemTemplateSelector}"
ItemsSelector="{StaticResource itemsSelector}"
ItemsSource="{Binding Departments}"
KeySelector="{StaticResource keySelector}"
DiagramItemAdding="DiagramDataBindingBehavior_DiagramItemAdding"
LayoutKind="Sugiyama" />
</dxmvvm:Interaction.Behaviors>
</dxdiag:DiagramDesignerControl>
</Grid>
</Window>