在保留所有引脚的同时如何命名我的不同引脚?
how can I name my different pins while I keep having them all?
当我这样做时:
var ourPin = new Pin {
//info
};
ourPin.Clicked += (sender, args) => {
//pushasync
};
map.Pins.Add (ourPin);
它有效,但如果我尝试在 add () 中向我的地图添加另一个图钉,我只能输入 1 个图钉。所以我这样做了,但我不知道我应该如何命名每个引脚:
map.Pins.Add (new Pin {
//info
});
map.Pins.Add(new Pin {
//info
});
//how can i pushasync each pin?
用这种方法我得到了两个引脚,但正如我上面提到的,我如何命名它们中的每一个以便我可以为每个引脚创建一个 Clickfunction?
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
}
当我这样做时:
var ourPin = new Pin {
//info
};
ourPin.Clicked += (sender, args) => {
//pushasync
};
map.Pins.Add (ourPin);
它有效,但如果我尝试在 add () 中向我的地图添加另一个图钉,我只能输入 1 个图钉。所以我这样做了,但我不知道我应该如何命名每个引脚:
map.Pins.Add (new Pin {
//info
});
map.Pins.Add(new Pin {
//info
});
//how can i pushasync each pin?
用这种方法我得到了两个引脚,但正如我上面提到的,我如何命名它们中的每一个以便我可以为每个引脚创建一个 Clickfunction?
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
}