当我一直拥有不同的别针时,我该如何命名它们呢
本文关键字:何命名 拥有 一直 | 更新日期: 2023-09-27 18:28:37
当我这样做时:
var ourPin = new Pin {
//info
};
ourPin.Clicked += (sender, args) => {
//pushasync
};
map.Pins.Add (ourPin);
它有效,但如果我试图在add()中向我的地图添加另一个pin,我只能输入1个pin。所以我改为这样做,但我不知道如何命名每个引脚:
map.Pins.Add (new Pin {
//info
});
map.Pins.Add(new Pin {
//info
});
//how can i pushasync each pin?
用这个方法我得到了这两个引脚,但正如我上面提到的,我如何命名它们中的每一个,以便我可以用每个引脚创建Click函数?
var pin = new Pin();
pin.Label = "Pin A";
pin.Address = "blah";
pin.Position = new Position(x1,y1);
pin.Clicked += Pin_Clicked;
map.Pins.Add(pin);
pin = new Pin();
pin.Label = "Pin B";
pin.Address = "blah";
pin.Position = new Position(x2,y2);
pin.Clicked += Pin_Clicked;
map.Pins.Add(pin);
pin = new Pin();
pin.Label = "Pin C";
pin.Address = "blah";
pin.Position = new Position(x3,y3);
pin.Clicked += Pin_Clicked;
map.Pins.Add(pin);
void Pin_Clicked (object sender, EventArgs e)
{
Pin pin = (Pin)sender;
// now pin is the Pin that was clicked, look at it's properties
// to determine which pin and act accordingly
}