popup is shown behind pin in UWP
I'm afraid you can't set the custom xaml elements on top of map, because currently, it does not provide such zindex poperty. So for this scenario, we suggest place the TextBlock in the MapItemsControl's DataTemplate, and give it left top value that to make sure the pin element will not covered.
<map:MapControl
x:Name="myMap"
HorizontalAlignment="Stretch"
VerticalAlignment="Stretch">
<map:MapItemsControl ItemsSource="{x:Bind ViewModel.Things}">
<map:MapItemsControl.ItemTemplate>
<DataTemplate>
<Grid>
<Canvas map:MapControl.Location="{Binding Location}">
<Path
Margin="0"
Data="M14-32h-28v27h8l6 5 6-5h8z"
Fill="HotPink"
IsHitTestVisible="True"
Stroke="Black"
StrokeThickness="2">
<interactivity:Interaction.Behaviors>
<core:EventTriggerBehavior EventName="Tapped">
<core:InvokeCommandAction Command="{Binding SelectMeCommand, Mode=OneWay}" />
</core:EventTriggerBehavior>
</interactivity:Interaction.Behaviors>
</Path>
<Grid
Canvas.Left="16"
Canvas.Top="-40"
Width="300"
Height="30"
Background="Blue"
Canvas.ZIndex="0"
Visibility="{Binding Avaiable}">
<TextBlock Text="{Binding Name, Mode=OneWay}" />
</Grid>
</Canvas>
</Grid>
</DataTemplate>
</map:MapItemsControl.ItemTemplate>
</map:MapItemsControl>
<map:MapElementsLayer />
ViewModel
public class MainViewModel : BaseViewModel
{
public MainViewModel()
{
Things = new ObservableCollection<Thing>
{
new Thing("Place One", 17.4947934, 78.3996441, SelectMe),
new Thing("Place Two", 17.3616, 78.4747, SelectMe),
new Thing("Place Three", 17.4375, 78.4482, SelectMe),
new Thing("Place Four", 17.3930, 78.4730, SelectMe)
};
}
public ObservableCollection<Thing> Things { get; }
private Thing _selectedThing;
public Thing SelectedThing { get => _selectedThing; private set => SetProperty(ref _selectedThing, value); }
private Thing previousThing;
private void SelectMe(Thing thing)
{
if (previousThing != null)
{
previousThing.Avaiable = false;
}
if (thing != null)
{
thing.Avaiable = true;
previousThing = thing;
}
}
}
public class Thing : BaseViewModel
{
public Thing(string name, double latitude, double longitude, Action<Thing> selector)
{
Name = name;
Location = new Geopoint(new BasicGeoposition { Latitude = latitude, Longitude = longitude });
SelectMeCommand = new RelayCommand(() => selector(this));
}
public string Name { get; set; }
public Geopoint Location { get; set; }
public ICommand SelectMeCommand { get; }
private bool _avaiable;
public bool Avaiable
{
get => _avaiable;
set => SetProperty(ref _avaiable, value);
}
}