我有一个带有bing映射的WPF应用程序。我尝试在地图图层上添加几个图钉。这很好用,但是如果两个或多个图钉彼此靠近,则只能看到其中一个。我检查了一下,所有图钉都添加到了图层中,但是看不到所有图钉。插针永远不在同一位置,所以我应该至少看到每个插针的一小部分。
下面是我用来添加引脚的代码。当我在调试模式下浏览代码时,所有引脚都被添加并且可见。如果我只是让应用程序运行,它将无法正常工作。 有没有人知道这种行为的原因是什么?
Private Sub putPin(name As String, color As Color, bez As String)
Dim count As Integer = 1
For Each dr As DataRow In ds.Tables("Table1").Rows
If dr("Energietr").ToString.Contains(name) Then
Dim pin As New Pushpin()
count += 1
Dim pinLocation As Location = New Location(CDbl(dr("Breite")), CDbl(dr("Länge")))
pin.Location = pinLocation
pin.Background = New System.Windows.Media.SolidColorBrush(color)
pin.BorderBrush = New System.Windows.Media.SolidColorBrush(color)
pin.Name = bez & count & "_" & dr("Kraftwerksnummer Bundesnetzagentur").ToString
AddHandler pin.MouseEnter, AddressOf Pushpin_MouseEnter
AddHandler pin.MouseLeave, AddressOf Pushpin_MouseLeave
pinLayer.Children.Add(pin)
Threading.Thread.Sleep(5)
End If
Next
End Sub
编辑:如果我添加一个thread.sleep几毫秒,则图钉变为可见。但是,这不是解决方案,因为应用程序变得太慢了……