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
|
Partial Public Class MainPage
Inherits UserControl
Public Sub New()
InitializeComponent()
Dim Liste As New List(Of MonObjet)
Liste.Add(New MonObjet("Un"))
Liste.Add(New MonObjet("Deux", , 1))
Liste.Add(New MonObjet("Trois", 1, 1))
Me.myGrid.ItemsSource = Liste
End Sub
End Class
Public Class MonObjet
Public Property Libelle As String
Public Property Prop1 As Object
Public Property Prop2 As Object
Sub New(lbl As String, Optional pr1 As Object = Nothing, Optional pr2 As Object = Nothing)
Me.Libelle = lbl
Me.Prop1 = pr1
Me.Prop2 = pr2
End Sub
Public ReadOnly Property Weight() As FontWeight
' renvoie FontWeights.Bold (gras) si Prop1 = null et Prop2 <> null
Get
Return If(Me.Prop1 = Nothing, If(Me.Prop2 = Nothing, FontWeights.Normal, FontWeights.Bold), FontWeights.Normal)
End Get
End Property
Public ReadOnly Property Style() As FontStyle
' renvoie FontStyle.Italic si Prop1 = null et Prop2 = null
Get
Return If(Me.Prop1 = Nothing AndAlso Me.Prop2 = Nothing, FontStyles.Italic, FontStyles.Normal)
End Get
End Property
Public ReadOnly Property Couleur() As SolidColorBrush
' renvoie Gray si Prop1 n'est pas null, sinon noir
Get
Return New SolidColorBrush(If(Me.Prop1 <> Nothing, Colors.Gray, Colors.Black))
End Get
End Property
End Class |
Partager