' Color Map Elements according to Female to Male ratio
Private Sub statesLayer_Imported(ByVal sender As Object, ByVal e As MapLayerImportEventArgs)
Dim layer As MapLayer = TryCast(sender, MapLayer)
' Declare brushes
Dim b1 As New SolidColorBrush(Colors.Orange)
Dim b2 As New SolidColorBrush(Color.FromArgb(255, 30, 144, 255))
For Each element As MapElement In layer.Elements
Dim males As Double = CDbl(element.GetProperty("MALES"))
Dim females As Double = CDbl(element.GetProperty("FEMALES"))
Dim ratio As Double = Math.Round(females / males, 2)
element.ToolTip = String.Format("{0:F2}", females / males)
element.Caption = DirectCast(element.GetProperty("STATE_ABBR"), String)
' Check ratio and set color
If ratio > 1 Then
element.Fill = b1
Else
element.Fill = b2
End If
Next
End Sub