Commands in WPF Maps (SfMap)

23 Jul 20213 minutes to read

The WPF Map control contains the following commands:

  • ZoomIn Command
  • ZoomOut Command
  • Pan Command
  • ZoomReset Command
  • PanReset Command

ZoomIn Command

ZoomIn command zooms in the map.

ZoomOut Command

ZoomOut command zooms out the map.

Pan Command

PanCommand is used to navigate on the Map control. The direction of the navigation is the Command parameter for the Pan Command.

ZoomReset Command

The ZoomResetCommand resets the ZoomLevel value of the Map control.

PanReset Command

The PanResetCommand resets the map at its initial position; it resets the pan values.

  • XAML
  • <Grid Margin="10">
                <RowDefinition Height="Auto"/>
            <syncfusion:SfMap x:Name="Map">
                    <syncfusion:ShapeFileLayer  x:Name="shapeControl" Uri="DataMarkers.ShapeFiles.world1.shp">
            </syncfusion:SfMap >
            <StackPanel Grid.Row="1" Orientation="Horizontal" Margin="10">
                    <Style TargetType="Button">
                        <Setter Property="Margin" Value="5"/>
                        <Setter Property="Padding" Value="5"/>
                <Button Content="ZoomIn" Command="{Binding ElementName=Map,Path=ZoomInCommand}"/>
                <Button Content="ZoomOut" Command="{Binding ElementName=Map,Path=ZoomOutCommand}"/>
                <!--Panning commands-->
                <Button Content="LeftPan" Command="{Binding ElementName=Map,Path=PanCommand}" CommandParameter="left"/>
                <Button Content="RightPan" Command="{Binding ElementName=Map,Path=PanCommand}" CommandParameter="right"/>
                <Button Content="TopPan" Command="{Binding ElementName=Map,Path=PanCommand}" CommandParameter="top"/>
                <Button Content="BottomPan" Command="{Binding ElementName=Map,Path=PanCommand}" CommandParameter="bottom"/>
                <Button Content="ZoomReset" Command="{Binding ElementName=Map,Path=ZoomResetCommand}"/>
                <Button Content="PanReset" Command="{Binding ElementName=Map,Path=PanResetCommand}"/>


    You can also explore our WPF Map example to know how to render and configure the map.