1

[VB2012] 次のコードを使用して、データベースから Bing Maps WPF MapLayer (ml) に画鋲を繰り返し追加しています。

Dim pp As New Pushpin()
pp.Location = New Location(utm.Latitude.GetDecimalCoordinate, utm.Longitude.GetDecimalCoordinate)
pp.PositionOrigin = PositionOrigin.BottomCenter
pp.Content = PinLabel
pp.ToolTip = PinLabel
pp.FontSize = 6.0R
' need to put an AddHandler in here
ml.Children.Add(pp)

画鋲が追加され、maplayer に表示されます。私が理解していないのは、画鋲がクリックされたときに判断できるように、画鋲ごとに AddHandler を追加する方法です。いくつかの洞察をいただければ幸いです。私が見つけたオンラインの例から、私がする必要があることがわかりません。

4

1 に答える 1

1

WPF の Addhandler ステートメントは、他の VB.Net アプリケーションと同じ構造です。すべての画鋲がこのイベントにルーティングされるため、sender オブジェクトが正しいものを取得します。

Addhandler pp.MouseDown, AddressOf pp_MouseDown

イベントに一致する署名でサブルーチンを作成する必要があります。

Private Sub pp_MouseDown(sender As Object, e As RoutedEventArgs)
  'sender is the PushPin in question
  Dim pp as PushPin = DirectCast(sender, PushPin)
End Sub
于 2013-03-17T15:57:09.563 に答える