/
MainWindow.xaml.vb
190 lines (177 loc) · 6.07 KB
/
MainWindow.xaml.vb
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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
Imports Microsoft.VisualBasic
Imports System
Imports System.Collections.Generic
Imports System.Linq
Imports System.Text
Imports System.Windows
Imports System.Windows.Controls
Imports System.Windows.Data
Imports System.Windows.Documents
Imports System.Windows.Input
Imports System.Windows.Media
Imports System.Windows.Media.Imaging
Imports System.Windows.Navigation
Imports System.Windows.Shapes
Imports DevExpress.Xpf.Grid
Namespace WpfApplication18
''' <summary>
''' Interaction logic for MainWindow.xaml
''' </summary>
Partial Public Class MainWindow
Inherits Window
Public Sub New()
InitializeComponent()
End Sub
Private Sub Window_Loaded(ByVal sender As Object, ByVal e As RoutedEventArgs)
gridControl1.ItemsSource = Employees
End Sub
#Region "#GridInCode"
Private Sub Button_Click(ByVal sender As Object, ByVal e As RoutedEventArgs)
Dim newGrid As GridControl = CreateGrid()
AddDetailsToGrid(newGrid)
Grid.SetRow(newGrid, 2)
mainGrid.Children.Add(newGrid)
End Sub
Private Function CreateGrid() As GridControl
Dim newGrid As New GridControl()
newGrid.AutoGenerateColumns = AutoGenerateColumnsMode.AddNew
newGrid.View = New TableView()
TryCast(newGrid.View, TableView).AutoWidth = True
TryCast(newGrid.View, TableView).ShowGroupPanel = False
newGrid.View.DetailHeaderContent = "Employees"
newGrid.ItemsSource = Employees
Return newGrid
End Function
Private Sub AddDetailsToGrid(ByVal grid As GridControl)
Dim dataControlDetail As New DataControlDetailDescriptor()
dataControlDetail.ItemsSourcePath = "Orders"
Dim detailGrid As New GridControl()
dataControlDetail.DataControl = detailGrid
detailGrid.AutoGenerateColumns = AutoGenerateColumnsMode.AddNew
detailGrid.View.DetailHeaderContent = "Orders"
TryCast(detailGrid.View, TableView).ShowGroupPanel = False
Dim contentDetail As New ContentDetailDescriptor()
contentDetail.ContentTemplate = CType(FindResource("EmployeeNotes"), DataTemplate)
contentDetail.HeaderContent = "Notes"
Dim tabDetail As New TabViewDetailDescriptor()
tabDetail.DetailDescriptors.Add(dataControlDetail)
tabDetail.DetailDescriptors.Add(contentDetail)
grid.DetailDescriptor = tabDetail
End Sub
#End Region ' #GridInCode
Private employees_Renamed As List(Of Employee)
Private ReadOnly Property Employees() As List(Of Employee)
Get
If employees_Renamed Is Nothing Then
PopulateEmployees()
End If
Return employees_Renamed
End Get
End Property
Private Sub PopulateEmployees()
employees_Renamed = New List(Of Employee)()
employees_Renamed.Add(New Employee("Bruce", "Cambell", "Sales Manager", "Education includes a BA in psychology from Colorado State University in 1970. He also completed 'The Art of the Cold Call.' Bruce is a member of Toastmasters International."))
employees_Renamed(0).Orders.Add(New Order("Suppliers Inc.", DateTime.Now, "TV", 20))
employees_Renamed(0).Orders.Add(New Order("Suppliers Inc.", DateTime.Now.AddDays(3), "Projector", 15))
employees_Renamed.Add(New Employee("Cindy", "Haneline", "Vice President of Sales", "Cindy received her BTS commercial in 1974 and a Ph.D. in international marketing from the University of Dallas in 1981. She is fluent in French and Italian and reads German. She joined the company as a sales representative, was promoted to sales manager in January 1992 and to vice president of sales in March 1993. Cindy is a member of the Sales Management Roundtable, the Seattle Chamber of Commerce, and the Pacific Rim Importers Association."))
employees_Renamed(1).Orders.Add(New Order("Suppliers Inc.", DateTime.Now.AddDays(1), "Blu-Ray Player", 10))
End Sub
End Class
Public Class Employee
Private firstName_Renamed As String
Private lastName_Renamed As String
Private title_Renamed As String
Private notes_Renamed As String
Private orders_Renamed As List(Of Order)
Public Sub New(ByVal firstName As String, ByVal lastName As String, ByVal title As String, ByVal notes As String)
Me.firstName_Renamed = firstName
Me.lastName_Renamed = lastName
Me.title_Renamed = title
Me.notes_Renamed = notes
Me.orders_Renamed = New List(Of Order)()
End Sub
Public Sub New()
End Sub
Public Property FirstName() As String
Get
Return firstName_Renamed
End Get
Set(ByVal value As String)
firstName_Renamed = value
End Set
End Property
Public Property LastName() As String
Get
Return lastName_Renamed
End Get
Set(ByVal value As String)
lastName_Renamed = value
End Set
End Property
Public Property Title() As String
Get
Return title_Renamed
End Get
Set(ByVal value As String)
title_Renamed = value
End Set
End Property
Public Property Notes() As String
Get
Return notes_Renamed
End Get
Set(ByVal value As String)
notes_Renamed = value
End Set
End Property
Public ReadOnly Property Orders() As List(Of Order)
Get
Return orders_Renamed
End Get
End Property
End Class
Public Class Order
Private supplier_Renamed As String
Private date_Renamed As DateTime
Private productName_Renamed As String
Private quantity_Renamed As Integer
Public Sub New(ByVal supplier As String, ByVal [date] As DateTime, ByVal productName As String, ByVal quantity As Integer)
Me.supplier_Renamed = supplier
Me.date_Renamed = [date]
Me.productName_Renamed = productName
Me.quantity_Renamed = quantity
End Sub
Public Property Supplier() As String
Get
Return supplier_Renamed
End Get
Set(ByVal value As String)
supplier_Renamed = value
End Set
End Property
Public Property [Date]() As DateTime
Get
Return date_Renamed
End Get
Set(ByVal value As DateTime)
date_Renamed = value
End Set
End Property
Public Property ProductName() As String
Get
Return productName_Renamed
End Get
Set(ByVal value As String)
productName_Renamed = value
End Set
End Property
Public Property Quantity() As Integer
Get
Return quantity_Renamed
End Get
Set(ByVal value As Integer)
quantity_Renamed = value
End Set
End Property
End Class
End Namespace