none
c#, wpf, navigation control

    Question

  • i am new in this area ....

    how is it possible to enable the navigation control 

    with silverlight it is quite easy ... you can use NavigationVisibility

    how it works in the wpf environment.

    alfred

    Tuesday, July 16, 2013 8:43 AM

Answers

  • There is no navigation control in the WPF control. you can easily create on though.  Here is an example:

    <Grid>
    	<m:Map Name="MyMap" ZoomLevel="{Binding Value, ElementName=ZoomBar, Mode=TwoWay}">
    		<m:Map.Children>
    			<m:MapLayer Name="DataLayer"/>
    		</m:Map.Children>
    	</m:Map>
    	<Grid HorizontalAlignment="Left" VerticalAlignment="Top" Height="290">
    		<Grid.ColumnDefinitions>
    			<ColumnDefinition Width="30"/>
    			<ColumnDefinition Width="30"/>
    			<ColumnDefinition Width="30"/>
    		</Grid.ColumnDefinitions>
    		<Grid.RowDefinitions>
    			<RowDefinition Height="30"/>
    			<RowDefinition Height="30"/>
    			<RowDefinition Height="30"/>
    			<RowDefinition/>
    		</Grid.RowDefinitions>
    
    		<Button Content="&#8657;" Width="25" Height="25" Grid.Column="1" Tag="Up" Click="PanMap_Click"/>
    		<Button Content="&#8658;" Width="25" Height="25" Grid.Row="1" Grid.Column="2" Tag="Right" Click="PanMap_Click"/>
    		<Button Content="&#8659;" Width="25" Height="25" Grid.Row="2" Grid.Column="1" Tag="Down" Click="PanMap_Click"/>
    		<Button Content="&#8656;" Width="25" Height="25" Grid.Row="1" Tag="Left" Click="PanMap_Click"/>
    		
    		<Slider Name="ZoomBar" Orientation="Vertical" Height="180" Width="20" Margin="10,10" Grid.ColumnSpan="3" Grid.Row="3"
    			 HorizontalAlignment="Center" Minimum="1" Maximum="19" SmallChange="1"/>
    	</Grid>        
    </Grid>

    Here is the code behind:

    private void PanMap_Click(object sender, RoutedEventArgs e)
    {
    	Button b = sender as Button;
    	Point p;
    	
    	MyMap.TryLocationToViewportPoint(MyMap.Center, out p);
    
    	if (p != null)
    	{
    		switch (b.Tag as string)
    		{
    			case "Up":
    				p.Y -= 50;
    				break;
    			case "Down":
    				p.Y += 50;
    				break;
    			case "Left":
    				p.X -= 50;
    				break;
    			case "Right":
    				p.X += 50;
    				break;
    		}
    
    		Microsoft.Maps.MapControl.WPF.Location l;
    		MyMap.TryViewportPointToLocation(p, out l);
    		MyMap.SetView(l, MyMap.ZoomLevel);
    	}
    }
    


    http://rbrundritt.wordpress.com


    Tuesday, July 16, 2013 9:29 AM
    Owner

All replies

  • There is no navigation control in the WPF control. you can easily create on though.  Here is an example:

    <Grid>
    	<m:Map Name="MyMap" ZoomLevel="{Binding Value, ElementName=ZoomBar, Mode=TwoWay}">
    		<m:Map.Children>
    			<m:MapLayer Name="DataLayer"/>
    		</m:Map.Children>
    	</m:Map>
    	<Grid HorizontalAlignment="Left" VerticalAlignment="Top" Height="290">
    		<Grid.ColumnDefinitions>
    			<ColumnDefinition Width="30"/>
    			<ColumnDefinition Width="30"/>
    			<ColumnDefinition Width="30"/>
    		</Grid.ColumnDefinitions>
    		<Grid.RowDefinitions>
    			<RowDefinition Height="30"/>
    			<RowDefinition Height="30"/>
    			<RowDefinition Height="30"/>
    			<RowDefinition/>
    		</Grid.RowDefinitions>
    
    		<Button Content="&#8657;" Width="25" Height="25" Grid.Column="1" Tag="Up" Click="PanMap_Click"/>
    		<Button Content="&#8658;" Width="25" Height="25" Grid.Row="1" Grid.Column="2" Tag="Right" Click="PanMap_Click"/>
    		<Button Content="&#8659;" Width="25" Height="25" Grid.Row="2" Grid.Column="1" Tag="Down" Click="PanMap_Click"/>
    		<Button Content="&#8656;" Width="25" Height="25" Grid.Row="1" Tag="Left" Click="PanMap_Click"/>
    		
    		<Slider Name="ZoomBar" Orientation="Vertical" Height="180" Width="20" Margin="10,10" Grid.ColumnSpan="3" Grid.Row="3"
    			 HorizontalAlignment="Center" Minimum="1" Maximum="19" SmallChange="1"/>
    	</Grid>        
    </Grid>

    Here is the code behind:

    private void PanMap_Click(object sender, RoutedEventArgs e)
    {
    	Button b = sender as Button;
    	Point p;
    	
    	MyMap.TryLocationToViewportPoint(MyMap.Center, out p);
    
    	if (p != null)
    	{
    		switch (b.Tag as string)
    		{
    			case "Up":
    				p.Y -= 50;
    				break;
    			case "Down":
    				p.Y += 50;
    				break;
    			case "Left":
    				p.X -= 50;
    				break;
    			case "Right":
    				p.X += 50;
    				break;
    		}
    
    		Microsoft.Maps.MapControl.WPF.Location l;
    		MyMap.TryViewportPointToLocation(p, out l);
    		MyMap.SetView(l, MyMap.ZoomLevel);
    	}
    }
    


    http://rbrundritt.wordpress.com


    Tuesday, July 16, 2013 9:29 AM
    Owner
  • that works great!!!!

    many thanks for the helpful code


    -----

    Wednesday, July 17, 2013 6:58 AM