2015-04-30 48 views
1

這些都做工精細

現在,用戶拖動地圖和火我ondrag當處理器

然後我想要刷新引腳以反映新的視圖區域 這也適用 - 除了現在的t上的Clicked事件他的針腳被忽略。顯示信息框,但當單擊信息框時,處理程序本身不會被調用。這在第一次設置時起作用,但在引腳改變之後不起作用。

我試圖拖就創造新的引腳:

map.Pins.Clear(); 
foreach (Place p in PlaceList){ 
    Pin newPin = new Pin(); 
    pin.Label = p.PlaceName; 
    pin.Clicked += DoPinClick; 
} 

,然後我試着拖動重用現有引腳:

Pin pin; 
for (int i = 0; i < PlaceList.Count; i++) { 
    if (i > 9) 
    // max of 10 pins 
    break; 
    Place p = PlaceList [i]; 
    if (i >= map.Pins.Count - 1) { 
    // a new pin to be created and added to the map pins 
    pin = new Pin(); 
    pin.Clicked += DoPinClick; 
    pin.Label = p.PlaceName; 
    map.Pins.Add (pin); 
    } else { 
    // there was already a pin in that slot, get it and reuse it 
    pin = map.Pins [i]; 
    pin.Label = p.PlaceName; 
    } 
    pin.Position = p.Position; 
    // copy the pin into the slot it occupies already 
    map.Pins [i] = pin; 
} 

但是我按照事件處理兩者的做法只能等到我改變引腳。

+0

它可能並不重要,但你有沒有嘗試刪除該事件處理程序清除現有列表之前? –

+0

我沒有,但我只是試過,沒有區別。 – WillG

回答

0

這似乎是Xamarin的一個錯誤。

Bug report 25557

Bug report 29017

+0

沒有這些是早先的錯誤,阻止事件觸發。我在xamarin.forms.maps 1.4.2.6355上,現在事件觸發 - 直到我更改Map.Pins集合,然後它再也不會再次觸發 – WillG

+0

嗯,我在我的應用程序中做同樣的事情,所以它看起來像一個很好,我打算也遇到這個問題。 –