-
Notifications
You must be signed in to change notification settings - Fork 0
/
ViewModel.vb
54 lines (44 loc) · 1.37 KB
/
ViewModel.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
Imports DevExpress.Mvvm
Imports DevExpress.Mvvm.DataAnnotations
Imports System.Collections.ObjectModel
Namespace E2042
Public Class ViewModel
Inherits ViewModelBase
Public Sub New()
SetNewData()
End Sub
Public Property List As ObservableCollection(Of Task)
Public Sub SetNewData()
If List Is Nothing Then
List = New ObservableCollection(Of Task)()
Else
List.Clear()
End If
For i As Integer = 0 To 20 - 1
List.Add(New Task() With {.Num = i, .Name = "Name " & i * (i + 10), .IsCompleted = i Mod 2 = 0})
Next
End Sub
<Command>
Public Sub ChangeSource()
SetNewData()
End Sub
<Command>
Public Sub ChangeItem()
If List IsNot Nothing AndAlso List.Count > 0 Then
List(0).Num = 1000000000
End If
End Sub
<Command>
Public Sub AddNewItem()
If List IsNot Nothing Then
List.Add(New Task() With {.Num = 0, .Name = "Additional New Item"})
End If
End Sub
<Command>
Public Sub DeleteItem()
If List IsNot Nothing AndAlso List.Count > 0 Then
List.RemoveAt(List.Count - 1)
End If
End Sub
End Class
End Namespace