Make clickable UI-elements for windows Phone 8.1 a

2019-08-13 14:57发布

问题:

Windows Phone 8.1 App , C#

I would like to let the user add Pushpins ( which apparently are called MapIcons ) to the map and when the user clicks the newly created Pushpin some other ui-elements should appear.

But apparently MapIcons are not clickable and you can not inherit from them since they are sealed, so no luck in making them clickable.

I tried to just extend from Windows.UI.Xaml.Controls.Button , but those have not Location, probably because the do not belong to the Windows.UI.Xaml.Controls.Maps-namespace. So I can not really add them to the Windows.UI.Xaml.Controls.Maps.MapControl.Children or Windows.UI.Xaml.Controls.Maps.MapControl.MapElements, since they will not be on the map where I would want them to be.

So how do you make a clickable ui-element that I can give a location on the map?

回答1:

You can throw pretty much anything you want on there and just bind to the MapControl.Location attached property for the object placement as long as they're children of a map parent.

See more detail explanation here in the docs.