Class MainWindowクラスの全コード
Imports System.Reflection
Class MainWindow
Public Sub New()
' この呼び出しはデザイナーで必要です。
InitializeComponent()
Dim ColorList = From C In GetType(Colors).GetProperties() _
Select New ColorItem With {.Name = C.Name, .Color = CType(C.GetValue(Nothing, Nothing), Color)}
listColors.ItemsSource = ColorList
End Sub
End Class
Public Class ColorItem
Private _Name As String
Private _Color As Color
Public Property Name() As String
Get
Return _Name
End Get
Set(ByVal value As String)
_Name = value
End Set
End Property
Public Property Color() As Color
Get
Return _Color
End Get
Set(ByVal value As Color)
_Color = value
End Set
End Property
Public ReadOnly Property Brush() As Brush
Get
Return New SolidColorBrush(_Color)
End Get
End Property
End Class