0

How can I find out if two brushes are equal

tColor1 = New BrushConverter().ConvertFrom("#FF89DE93")
tColor2 = New BrushConverter().ConvertFrom("#FF89DE93")
tColor3 = Brushes.LightGray

How can I compare these burshes and get true for tColor1 = tColor2 and false for tColor1 = tColor3?

donL
  • 1,290
  • 3
  • 13
  • 37

1 Answers1

1
    Dim tColor1 As SolidColorBrush = CType(New BrushConverter().ConvertFrom("#FF89DE93"), SolidColorBrush)
    Dim tColor2 As SolidColorBrush = CType(New BrushConverter().ConvertFrom("#FF89DE93"), SolidColorBrush)
    Dim tColor3 = Brushes.LightGray

    Dim test As Boolean


    test = tColor1.Color = tColor2.Color 'True
    test = tColor1.Color = tColor3.Color 'False
Ceres
  • 3,524
  • 3
  • 18
  • 25
  • This works but is there not a way to compare without converting each item I want to compare? If I don't find a better option or a better explanation, I will mark this as the answer. – donL Nov 12 '13 at 23:10
  • What do you mean be converting? CType simply casts, it doesn't convert. Or do you mean using the BrushConverter().ConvertFrom call? – Ceres Nov 13 '13 at 13:50
  • sorry, mistaken choice of words. I mean cast. – donL Nov 13 '13 at 16:50