Select to view content in your preferred language

Feature Data Sample from ArcGIS API for Silverlight

653
3
01-17-2011 09:53 AM
JoannaLaroussi
Emerging Contributor
I am working through samples provided by ESRI and I again hit a problem. Here is xaml with my changes just in the first line:
<UserControl x:Class="FeatureDataSample.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">

        <esri:Map x:Name="MyMap" Extent="-122.4545596,37.783443296,-122.4449924,37.786447331">

            <esri:ArcGISTiledMapServiceLayer ID="BaseLayer"
    Url="http://services.arcgisonline.com/ArcGIS/rest/services/ESRI_StreetMap_World_2D/MapServer" />

            <esri:FeatureLayer ID="PointLayer"
                               Url="http://sampleserver3.arcgisonline.com/ArcGIS/rest/services/SanFrancisco/311Incidents/FeatureServer/0"
                               MouseLeftButtonUp="FeatureLayer_MouseLeftButtonUp"
                               DisableClientCaching="True"
                               Mode="OnDemand"
                               SelectionColor="#FFFFFF00"
                               OutFields="*" />
        </esri:Map>

        <Border x:Name="FeatureDataFormBorder" Visibility="Collapsed"
                HorizontalAlignment="Right" VerticalAlignment="Top" Margin="10,10,10,0" Width="300" Height="300" >
            <Border.Effect>
                <DropShadowEffect Color="Black" Direction="-45" BlurRadius="20" Opacity=".75" />
            </Border.Effect>
            <esri:FeatureDataForm x:Name="MyFeatureDataForm"  
                                         FeatureLayer="{Binding Path=Layers[PointLayer], ElementName=MyMap}"
                                         IsReadOnly="False" LabelPosition="Left" />
        </Border>

        <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="Click on a feature in the map to view the attributes in the data form.  Edit values in the data form and click ok to save to the database."
                       Width="200" TextAlignment="Left" Margin="30,20,20,30" TextWrapping="Wrap" />
        </Grid>

    </Grid>
    </UserControl>


And here is xaml.cs with changes only in namespace in three bold lines:
using System.Linq;
using System.Windows;
using System.Windows.Controls;
using ESRI.ArcGIS.Client;
using ESRI.ArcGIS.Client.Behaviors;
using ESRI.ArcGIS.Client.Toolkit;
using ESRI.ArcGIS.Client.Toolkit.DataSources;
using ESRI.ArcGIS.Client.WebMap;

namespace FeatureDataSample
{
    public partial class MainPage : UserControl
    {
        public MainPage()
        {
            InitializeComponent();
        }

        private void FeatureLayer_MouseLeftButtonUp(object sender, GraphicMouseButtonEventArgs args)
        {
            FeatureLayer featureLayer = sender as FeatureLayer;

            for (int i = 0; i < featureLayer.SelectionCount; i++)
                featureLayer.SelectedGraphics.ToList().UnSelect();

            args.Graphic.Select();
            MyFeatureDataForm.GraphicSource = args.Graphic;

            FeatureDataFormBorder.Visibility = Visibility.Visible;
        }
    }
}


I added all possible references ESRI.ArcGIS.Client, Client.Behaviors, Client.Toolkit, Client.Toolkit.DataSources. Client.WebMap, but I am still receiving some weird error:
Error 1,2 The type or namespace name 'FeatureDataForm' could not be found (are you missing a using directive or an assembly reference?)
Referring to lines from MainPage.g.i.cs
internal FeatureDataForm MyFeatureDataForm;
this.MyFeatureDataForm = ((FeatureDataForm)(this.FindName("MyFeatureDataForm")));


Any ideas?
0 Kudos
3 Replies
DanielWalton
Frequent Contributor
I would recommend re-downloading the sample without any changes made and running it to make sure you have all the correct libraries installed on your computer. Then make changes one at a time to see how they impact the compiler. It's a good way to lean how references and namespaces work in Silverlight / .NET.
0 Kudos
JenniferNery
Esri Regular Contributor
You might want to try what Dan suggested.

But if you want to troubleshoot your existing application. I know that FeatureDataForm also uses a .NET Assembly System.Windows.Controls.Data.Input. Try adding a reference to this in your project and see if that works.
0 Kudos
JoannaLaroussi
Emerging Contributor
Thanks a lot! It is working now 🙂
0 Kudos