1
votes

I am using UWP MapControl.

The problem I get with this XAML is that when I Right click on map, Flyout Menu doesn't appear.

<Maps:MapControl Name="MapaElementov" HorizontalAlignment="Left" Margin="10,47,0,0" VerticalAlignment="Top" Height="663" Width="1260" MapServiceToken="some-code"
                      ZoomLevel="9" RotateInteractionMode="Disabled" TiltInteractionMode="Disabled">
        <Maps:MapControl.ContextFlyout>
            <MenuFlyout>

            </MenuFlyout>
        </Maps:MapControl.ContextFlyout>
    </Maps:MapControl>

What am I doing wrong here?

1

1 Answers

2
votes

When I try to run your example, it doesn't even compile. I get this error message pointing on the line with ContextFlyout:

The XAML Binary Format (XBF) generator reported syntax error '0x09c5'

Perhaps MapControl isn't allowed to have ContextFlyout? So alternatively, you can achieve same result with this code:

<maps:MapControl Name="MapaElementov" HorizontalAlignment="Left" Margin="10,47,0,0" VerticalAlignment="Top" Height="663" Width="1260" MapServiceToken="some-code"
                 ZoomLevel="9" RotateInteractionMode="Disabled" TiltInteractionMode="Disabled" MapRightTapped="MapaElementov_MapRightTapped">

    <FlyoutBase.AttachedFlyout>
        <MenuFlyout x:Name="MapFlyout">
            <MenuFlyoutItem Text="Item 1"/>
            <MenuFlyoutItem Text="Item 2"/>
        </MenuFlyout>
    </FlyoutBase.AttachedFlyout>
</maps:MapControl>

...

private void MapaElementov_MapRightTapped(MapControl sender, MapRightTappedEventArgs args)
{
    MapFlyout.ShowAt(sender, new Point(args.Position.X, args.Position.Y));
}

I think you can also easily pack this into your own attached property, if you want.

EDIT: I couldn't compile your example because, apparantely, ContextFlyout was introduced in Anniversary Update, so I had to set min and target version to build 14393 to run it.