FeatureDataGrid not compile.

434
4
04-18-2012 11:30 AM
GeneLiu
New Contributor
I have copied a sample from http://help.arcgis.com/en/webapi/silverlight/samples/start.htm#ToolkitFeatureDataGrid.
I have included all the GIS related references:
ESRI.ArcGIS.Client
ESRI.ArcGIS.Client.Behaviors
ESRI.ArcGIS.Client.Bing
ESRI.ArcGIS.Client.Toolkit
ESRI.ArcGIS.Client.Toolkit.DataSources
ESRI.ArcGIS.Client.WebMap

I also include the window related references:
System.Windows.Controls
System.Windows.Controls.Data
System.Windows.Controls.Data.Input


I cannot compile it. The error is:
Error 1 The type or namespace name 'FeatureDataGrid' could not be found (are you missing a using directive or an assembly reference?) ~\samples\toolkit controls\featuredatagrid\MuellerFeatureDataGrid\MuellerFeatureDataGrid\obj\Debug\MainPage.g.i.cs 40

Please help,
Thanks a lot.


Here is the code in mainpage.xaml
<UserControl x:Class="ArcGISSilverlightSDK.MainPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:basics="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls"
    xmlns:sys="clr-namespace:System;assembly=mscorlib"
xmlns:esri="http://schemas.esri.com/arcgis/client/2009">
    <Grid Background="White">

        <Grid.RowDefinitions>
            <RowDefinition Height="*" />
            <RowDefinition Height="5" />
            <RowDefinition Height="150" />
        </Grid.RowDefinitions>

        <esri:Map x:Name="MyMap" WrapAround="True">
            <esri:ArcGISTiledMapServiceLayer ID="StreetMapLayer"
                    Url="http://services.arcgisonline.com/ArcGIS/rest/services/World_Street_Map/MapServer"/>
            <esri:FeatureLayer ID="IncidentsLayer"
                               Url="http://sampleserver3.arcgisonline.com/ArcGIS/rest/services/SanFrancisco/311Incidents/FeatureServer/0"
                               DisableClientCaching="True"                               
                               Mode="OnDemand"
                               AutoSave="False"
                               OnDemandCacheSize="0"
                               OutFields="req_id,req_date,req_time,address,district,status"
                               MouseLeftButtonUp="FeatureLayer_MouseLeftButtonUp">
                <esri:FeatureLayer.MapTip>
                    <Border CornerRadius="10" BorderBrush="#FF222957" Background="AliceBlue" BorderThickness="3" Margin="0,0,15,15">
                        <Border.Effect>
                            <DropShadowEffect ShadowDepth="10" BlurRadius="14" Direction="300" />
                        </Border.Effect>
                        <StackPanel Margin="7">
                            <TextBlock Text="{Binding [req_id]}" FontWeight="Bold" Foreground="Black"  />
                            <StackPanel Orientation="Horizontal">
                                <TextBlock Text="Request: " Foreground="Black" />
                                <TextBlock Text="{Binding [req_type]}" Foreground="Black" />
                            </StackPanel>
                            <StackPanel Orientation="Horizontal">
                                <TextBlock Text="Status: " Foreground="Black" />
                                <TextBlock Text="{Binding [status]}" Foreground="Black" />
                            </StackPanel>
                        </StackPanel>
                    </Border>
                </esri:FeatureLayer.MapTip>
            </esri:FeatureLayer>

        </esri:Map>

        <basics:GridSplitter Grid.Row="1" HorizontalAlignment="Stretch" />

        <esri:FeatureDataGrid Grid.Row="2" x:Name="MyDataGrid"
    Map="{Binding ElementName=MyMap}"
    GraphicsLayer="{Binding ElementName=MyMap, Path=Layers.[IncidentsLayer]}" />

        <Grid HorizontalAlignment="Left" VerticalAlignment="Top" Margin="10,10,10,0" >
            <Rectangle Fill="#77919191" Stroke="Gray"  RadiusX="10" RadiusY="10" Margin="0,0,0,5" >
                <Rectangle.Effect>
                    <DropShadowEffect/>
                </Rectangle.Effect>
            </Rectangle>
            <Rectangle Fill="#FFFFFFFF" Stroke="DarkGray" RadiusX="5" RadiusY="5" Margin="10,10,10,15" />
            <TextBlock x:Name="ResponseTextBlock" Text="Edit values in the data grid.  When finished, click the Commit button to save to the database."
                       Width="200" TextAlignment="Left" Margin="30,20,20,30" TextWrapping="Wrap" />
        </Grid>

    </Grid>
</UserControl>


Here is the code in mainpage.xaml.cs
using System.Windows.Controls;
using ESRI.ArcGIS.Client;
using ESRI.ArcGIS.Client.Geometry;

namespace ArcGISSilverlightSDK
{
    public partial class MainPage : UserControl
    {
        private Graphic _lastGraphic;
        private static ESRI.ArcGIS.Client.Projection.WebMercator _mercator =
            new ESRI.ArcGIS.Client.Projection.WebMercator();

        public MainPage()
        {
            InitializeComponent();

            ESRI.ArcGIS.Client.Geometry.Envelope initialExtent =
                    new ESRI.ArcGIS.Client.Geometry.Envelope(
                _mercator.FromGeographic(
                    new ESRI.ArcGIS.Client.Geometry.MapPoint(-122.4545596, 37.783443296)) as MapPoint,
                _mercator.FromGeographic(
                    new ESRI.ArcGIS.Client.Geometry.MapPoint(-122.4449924, 37.786447331)) as MapPoint);

            initialExtent.SpatialReference = new SpatialReference(102100);

            MyMap.Extent = initialExtent;
        }

        private void FeatureLayer_MouseLeftButtonUp(object sender, GraphicMouseButtonEventArgs e)
        {
            if (_lastGraphic != null)
                _lastGraphic.UnSelect();

            e.Graphic.Select();
            if (e.Graphic.Selected)
                MyDataGrid.ScrollIntoView(e.Graphic, null);

            _lastGraphic = e.Graphic;
        }
    }
}
0 Kudos
4 Replies
DominiqueBroux
Esri Frequent Contributor
Might be a mismatch in your referenced ESRI dlls.

Double check the version of the dlls that your project references.
Clean your solution.
Exit visual studio.
Remove bin and obj directory.
Try again. Hopefully that's enough:)
0 Kudos
GeneLiu
New Contributor
Thank you very much!
I did everything you suggested. I get the same compile error.
Here is the dll info I am reference to:
ESRI.ArcGIS.Client
ESRI.ArcGIS.Client.Behaviors
ESRI.ArcGIS.Client.Bing
ESRI.ArcGIS.Client.Toolkit
ESRI.ArcGIS.Client.Toolkit.DataSources
ESRI.ArcGIS.Client.WebMap

File version: 2.4.0.851
Product version: 2.4.0.851
Date modified: 1/10/2012

Are they a wrong version of DLLs?

Here are some more info about this.
If I remove the <esri:FeatureDataGrid ... variable from mainpage.xaml and define a local variable mainpage.xaml.cs,
such as,
            FeatureDataGrid fdg = new FeatureDataGrid()
            {
                //bindings ...
            }
I can pass compile. Does this mean the version of the DLLs is ok?

Please help,
Thanks a lot.
0 Kudos
GeneLiu
New Contributor
I found out this problem - FeatureDataGrid not working for Silverlight 5.

Thanks,
Gene
0 Kudos
ChristopherHill
Occasional Contributor
Hello,

Our 2.4 version is targeted at SL4. SL5 microsoft changed the version numbers on System.Windows.Data.dll which requires the FeatureDataGrid reference the new assembly. If you want to build for SL5 our latest release v3.0 Pre-Release was built and released for SL5.
0 Kudos