Tool Bar
View live sample | Download as a zip file
Description
Use "ToolbarControl.AddTool()" to add different tools into toolbar, such as ZoomTool(), PanTool(), ZoomLastTool(), and FullExtentTool().
How To Use
Copy and modify the codes below to meet your needs.
Code
                                XAML

<UserControl  
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:Controls="clr-namespace:SGWSilverlightAPI.Controls;assembly=SGWSilverlightAPI" x:Class="SilverlightApplication1.MainPage"
   
    mc:Ignorable="d"
    d:DesignHeight="300" d:DesignWidth="400">

    <Canvas x:Name="LayoutRoot" Background="White" Margin="0,0,0,0"/>
</UserControl>

CS

using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Controls.Primitives;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using SGWSilverlightAPI.Interface;
using SGWSilverlightAPI.Map;
using SGWSilverlightAPI.Layer;
using SGWSilverlightAPI.Geometry;
using SGWSilverlightAPI.Controls;
using SGWSilverlightAPI.Tracker;
using SGWSilverlightAPI.Navigate;
 
 
namespace SilverlightApplication1
{
    public partial class MainPage : UserControl
    {
        MapBase m_pMapBase = null;
        ToolbarControl m_pToolbar = null;

        public MainPage()
        {
            InitializeComponent();
            m_pMapBase = new MapBase();
            m_pMapBase.Width = 2000;
            m_pMapBase.Height = 1000;
            m_pMapBase.Background = new SolidColorBrush(Colors.White);
            LayoutRoot.Children.Add(m_pMapBase);

            CachedLayer pLayer1 = new CachedLayer();
            pLayer1.ResourcePath = "http://sgs.supergeo.com.tw/wr1/Agent.aspx";
            pLayer1.OnLayerLoaded += OnLayerLoaded1;
            m_pMapBase.AddLayer(pLayer1);

            PanTool pTool = new PanTool();
            pTool.AllowDblClick = false;
            pTool.AllowWheelZoom = true;
            pTool.Initial(m_pMapBase);
            m_pMapBase.SelectMapTool(pTool);

            //ADD TOOLBAR AND TOOLS
            m_pToolbar = new ToolbarControl();
            m_pToolbar.VerticalAlignment = System.Windows.VerticalAlignment.Top;
            m_pToolbar.HorizontalAlignment = System.Windows.HorizontalAlignment.Left;
            m_pToolbar.Margin = new Thickness(50, 10, 0, 0);
            m_pToolbar.Orientation = Orientation.Horizontal;
            LayoutRoot.Children.Add(m_pToolbar);

            //ADD ZOOM IN TOOL
            ZoomTool pZoomInTool = new ZoomTool();
            pZoomInTool.ZoomType = 0;

            //ADD ZOOM OUT TOOL
            ZoomTool pZoomOutTool = new ZoomTool();
            pZoomOutTool.ZoomType = 1;

            //ADD PAN TOOL
            PanTool ptool = new PanTool();
            ptool.AllowDblClick = false;
            ptool.AllowWheelZoom = true;

            MapZoomStep Step = new MapZoomStep(m_pMapBase);

            //ADD ZOOM TO PREVIOUS EXTENT TOOL
            ZoomLastTool zlPrevtool = new ZoomLastTool();
            zlPrevtool.ZoomStepObject = Step;
            zlPrevtool.ZoomType = ZoomLastTool.ZOOM_PREVIOUS;

            //ADD ZOOM TO NEXT EXTENT TOOL
            ZoomLastTool zlNexttool = new ZoomLastTool();
            zlNexttool.ZoomStepObject = Step;
            zlNexttool.ZoomType = ZoomLastTool.ZOOM_NEXT;

            //ADD ZOOM TO FULL EXTENT TOOL
            FullExtentTool ftool = new FullExtentTool();
            ftool.MapCommand(m_pMapBase);

            //ADD TOOLS TO TOOLBAR
            m_pToolbar.AddTool(m_pMapBase, pZoomInTool, "images/002-01.png", "");
            m_pToolbar.AddTool(m_pMapBase, pZoomOutTool, "images/002-02.png", "");
            m_pToolbar.AddTool(m_pMapBase, ptool, "images/002-03.png", "");
            m_pToolbar.AddTool(m_pMapBase, zlPrevtool, "images/002-05.png", "");
            m_pToolbar.AddTool(m_pMapBase, zlNexttool, "images/002-06.png", "");
            m_pToolbar.AddTool(m_pMapBase, ftool, "images/002-04.png", "");
        }

        private void OnLayerLoaded1(object sender, EventArgs e)
        {
            Envelope pExt = m_pMapBase.Layers[0].Extent;
            ITransformation pTrans = new ScaleTransformation(1);
            m_pMapBase.Transformation = pTrans;
            Envelope pext1 = new Envelope(64.055019, 32.082678, 90.826878, 8.949713);
            m_pMapBase.ZoomMapTo(pExt);
            m_pMapBase.Scale = m_pMapBase.Scale * 3;
            m_pMapBase.RefreshMap(true);
        }
    }
}