-
Notifications
You must be signed in to change notification settings - Fork 500
/
Copy pathClass1.vb
73 lines (65 loc) · 2.23 KB
/
Class1.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
Public Class Class1
End Class
'<SnippetDOMain>
Public Class AquariumServices
Inherits DependencyObject
Public Enum Buoyancy
Floats
Sinks
Drifts
End Enum
Public Shared ReadOnly BuoyancyProperty As DependencyProperty = _
DependencyProperty.RegisterAttached(
"Buoyancy", _
GetType(Buoyancy), _
GetType(AquariumServices), _
New PropertyMetadata(Buoyancy.Floats))
Public Sub SetBuoyancy(element As DependencyObject, value As Buoyancy)
element.SetValue(BuoyancyProperty, value)
End Sub
Public Function GetBuoyancy(element As DependencyObject) As Buoyancy
GetBuoyancy = CType(element.GetValue(BuoyancyProperty), Buoyancy)
End Function
End Class
'</SnippetDOMain>
'<SnippetDOSimpleDP>
Public Class Fish
Inherits Control
Public Shared ReadOnly SpeciesProperty As DependencyProperty = _
DependencyProperty.Register(
"Species", _
GetType(String), _
GetType(Fish), _
Nothing)
Public Property Species As String
Get
Species = CType(GetValue(SpeciesProperty), String)
End Get
Set(value As String)
SetValue(SpeciesProperty, value)
End Set
End Property
End Class
'</SnippetDOSimpleDP>
Public Class DependencyPropertyUtilities
'<SnippetDOCheckClear>
Public Shared Function ClearSetProperty(targetObject As DependencyObject, targetDP As DependencyProperty) As Boolean
If targetObject Is Nothing Or targetDP Is Nothing Then
Throw New ArgumentNullException()
End If
Dim localValue As Object = targetObject.ReadLocalValue(targetDP)
If localValue = DependencyProperty.UnsetValue Then
ClearSetProperty = False
Else
targetObject.ClearValue(targetDP)
ClearSetProperty = True
End If
End Function
'</SnippetDOCheckClear>
'<SnippetDPGetMetadata>
Public Shared Function GetDefaultValueForFrameworkDP(dpIdentifier As DependencyProperty) As Object
Dim metadataInfo As PropertyMetadata = dpIdentifier.GetMetadata(GetType(FrameworkElement))
GetDefaultValueForFrameworkDP = metadataInfo.DefaultValue
End Function
'</SnippetDPGetMetadata>
End Class