Select to view content in your preferred language

Toolbar example from ArcGIS API for Microsoft Silverlight

3876
8
01-17-2011 11:10 AM
JoannaLaroussi
Emerging Contributor
I tried to recreate Toolbar example, but I received this error:
Error 1 Could not load file or assembly 'System.Runtime.Serialization, Version=2.0.5.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e' or one of its dependencies. The system cannot find the file specified.

And I have no much idea how to fix it. Below is all xml code, any advices highly appreciated!

UserControl x:Class="toolbar.MainPage"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:esri="http://schemas.esri.com/arcgis/client/2009">
    <Grid x:Name="LayoutRoot" Background="White">

        <Grid.Resources>
            <esri:SimpleFillSymbol x:Key="DefaultFillSymbol" Fill="#33FF0000" BorderBrush="Red"
                                          BorderThickness="2" />
        </Grid.Resources>

        <esri:Map x:Name="MyMap" Extent="-33,-12.85,99.75,87.15"
                  ExtentChanged="MyMap_ExtentChanged">
            <esri:ArcGISTiledMapServiceLayer ID="StreetMapLayer"
                    Url="http://services.arcgisonline.com/ArcGIS/rest/services/ESRI_StreetMap_World_2D/MapServer" />
        </esri:Map>

        <Grid Height="110" HorizontalAlignment="Right" VerticalAlignment="Top" Margin="0,10,10,0" >
            <Rectangle Fill="#77919191" RadiusX="10" RadiusY="10" Margin="0,4,0,6" >
                <Rectangle.Effect>
                    <DropShadowEffect/>
                </Rectangle.Effect>
            </Rectangle>
            <Rectangle Fill="#CCFFFFFF" Stroke="DarkGray" RadiusX="5" RadiusY="5" Margin="10,10,10,15" />
            <StackPanel Orientation="Vertical">
                <esri:Toolbar x:Name="MyToolbar" MaxItemHeight="80" MaxItemWidth="80"
                    VerticalAlignment="Top" HorizontalAlignment="Center"
                    Loaded="MyToolbar_Loaded"
                    ToolbarItemClicked="MyToolbar_ToolbarItemClicked"
                    ToolbarIndexChanged="MyToolbar_ToolbarIndexChanged"
                    Width="450" Height="80">
                    <esri:Toolbar.Items>
                        <esri:ToolbarItemCollection>
                            <esri:ToolbarItem Text="Zoom In">
                                <esri:ToolbarItem.Content>
                                    <Image Source="/Assets/images/i_zoomin.png" Stretch="UniformToFill" Margin="5" />
                                </esri:ToolbarItem.Content>
                            </esri:ToolbarItem>
                            <esri:ToolbarItem Text="Zoom Out">
                                <esri:ToolbarItem.Content>
                                    <Image Source="/Assets/images/i_zoomout.png" Stretch="UniformToFill" Margin="5" />
                                </esri:ToolbarItem.Content>
                            </esri:ToolbarItem>
                            <esri:ToolbarItem Text="Pan">
                                <esri:ToolbarItem.Content>
                                    <Image Source="/Assets/images/i_pan.png" Stretch="UniformToFill" Margin="5" />
                                </esri:ToolbarItem.Content>
                            </esri:ToolbarItem>
                            <esri:ToolbarItem Text="Previous Extent" >
                                <esri:ToolbarItem.Content>
                                    <Image Source="/Assets/images/i_previous.png" IsHitTestVisible="False" Opacity="0.3" Stretch="UniformToFill" Margin="5"/>
                                </esri:ToolbarItem.Content>
                            </esri:ToolbarItem>
                            <esri:ToolbarItem Text="Next Extent">
                                <esri:ToolbarItem.Content>
                                    <Image Source="/Assets/images/i_next.png" IsHitTestVisible="False" Opacity="0.3" Stretch="UniformToFill" Margin="5"/>
                                </esri:ToolbarItem.Content>
                            </esri:ToolbarItem>
                            <esri:ToolbarItem Text="Full Extent">
                                <esri:ToolbarItem.Content>
                                    <Image Source="/Assets/images/i_globe.png" Stretch="UniformToFill" Margin="5" />
                                </esri:ToolbarItem.Content>
                            </esri:ToolbarItem>
                            <esri:ToolbarItem Text="Full Screen">
                                <esri:ToolbarItem.Content>
                                    <Image Source="/Assets/images/i_widget.png" Stretch="UniformToFill" Margin="5" />
                                </esri:ToolbarItem.Content>
                            </esri:ToolbarItem>
                        </esri:ToolbarItemCollection>
                    </esri:Toolbar.Items>
                </esri:Toolbar>
                <TextBlock x:Name="StatusTextBlock" Text="" FontWeight="Bold" HorizontalAlignment="Center"/>

            </StackPanel>
        </Grid>

    </Grid>
</UserControl>
0 Kudos
8 Replies
JenniferNery
Esri Regular Contributor
You just need to add reference to this .NET assembly "System.Runtime.Serialization" as the error suggests. This is related thread http://forums.arcgis.com/threads/2300-System.Runtime.Serialization-Version
0 Kudos
JoannaLaroussi
Emerging Contributor
Thanks a lot! It appears to work now, but I cannot see tools inside my toolbar. Can you think about something else what I can have missing in my code?

You just need to add reference to this .NET assembly "System.Runtime.Serialization" as the error suggests. This is related thread http://forums.arcgis.com/threads/2300-System.Runtime.Serialization-Version
0 Kudos
JenniferNery
Esri Regular Contributor
You might be missing the images in your project, which means Source property in the ToolbarItem Image is not resolved.
<Image Source="/Assets/images/i_zoomin.png" Stretch="UniformToFill" Margin="5" />


You can download the SDK sample that contains these images http://help.arcgis.com/en/webapi/silverlight/help/index.html#/Sample_Interactive_SDK/01660000000v000....

Or you can add other images to your project and update the Source property to point to those images. Or replace the whole ToolbarItem.Content from Image to some other control that does not require image. For example
<Button Content="Zoom In" Margin="5" />
0 Kudos
JoannaLaroussi
Emerging Contributor
Thank you for your answer. I do have installed SDK on my computer. Could you explain me step by step how to connect SDK examples with toolbar sample script to add images of tools to my project?
0 Kudos
JenniferNery
Esri Regular Contributor
This is related thread http://forums.arcgis.com/threads/14852-Toolbar-icons-are-not-visible (see Post #6).

In the SDK sample, you will find the Assets folder in the website project. Where you save the images is completely up to you. Basically, you add images to your project and update the Image Source property to point to that image location.
0 Kudos
dotMorten_esri
Esri Notable Contributor
Instead of messing with the toolbar, the simplest approach is instead to just put a set of buttons inside a stackpanel, and use their click event to perform an action.
0 Kudos
JoannaLaroussi
Emerging Contributor
Thank you for all your help. I was able to fix it:
<esri:Toolbar.Items>
                        <esri:ToolbarItemCollection>
                            <esri:ToolbarItem Text="Zoom In">
                                <esri:ToolbarItem.Content>
                                    <Image Source="http://help.arcgis.com/en/webapi/silverlight/samples/Assets/images/i_zoomin.png" Stretch="UniformToFill" Margin="5" />
                                </esri:ToolbarItem.Content>
                            </esri:ToolbarItem>
                            <esri:ToolbarItem Text="Zoom Out">
                                <esri:ToolbarItem.Content>
                                    <Image Source="http://help.arcgis.com/en/webapi/silverlight/samples/Assets/images/i_zoomout.png" Stretch="UniformToFill" Margin="5" />
                                </esri:ToolbarItem.Content>
                            </esri:ToolbarItem>
                            <esri:ToolbarItem Text="Pan">
                                <esri:ToolbarItem.Content>
                                    <Image Source="http://help.arcgis.com/en/webapi/silverlight/samples/Assets/images/i_pan.png" Stretch="UniformToFill" Margin="5" />
                                </esri:ToolbarItem.Content>
                            </esri:ToolbarItem>
                            <esri:ToolbarItem Text="Previous Extent" >
                                <esri:ToolbarItem.Content>
                                    <Image Source="http://help.arcgis.com/en/webapi/silverlight/samples/Assets/images/i_previous.png" IsHitTestVisible="False" Opacity="0.3" Stretch="UniformToFill" Margin="5"/>
                                </esri:ToolbarItem.Content>
                            </esri:ToolbarItem>
                            <esri:ToolbarItem Text="Next Extent">
                                <esri:ToolbarItem.Content>
                                    <Image Source="http://help.arcgis.com/en/webapi/silverlight/samples/Assets/images/i_next.png" IsHitTestVisible="False" Opacity="0.3" Stretch="UniformToFill" Margin="5"/>
                                </esri:ToolbarItem.Content>
                            </esri:ToolbarItem>
                            <esri:ToolbarItem Text="Full Extent">
                                <esri:ToolbarItem.Content>
                                    <Image Source="http://help.arcgis.com/en/webapi/silverlight/samples/Assets/images/i_globe.png" Stretch="UniformToFill" Margin="5" />
                                </esri:ToolbarItem.Content>
                            </esri:ToolbarItem>
                            <esri:ToolbarItem Text="Full Screen">
                                <esri:ToolbarItem.Content>
                                    <Image Source="http://help.arcgis.com/en/webapi/silverlight/samples/Assets/images/i_widget.png" Stretch="UniformToFill" Margin="5" />
                                </esri:ToolbarItem.Content>
                            </esri:ToolbarItem>
                        </esri:ToolbarItemCollection>
                    </esri:Toolbar.Items>
                </esri:Toolbar>
0 Kudos
JenniferNery
Esri Regular Contributor
This just means you need to add reference to a .NET assembly. This is related thread http://forums.arcgis.com/threads/2300-System.Runtime.Serialization-Version
0 Kudos