Select to view content in your preferred language

FindResult from DataGrid doesnt work

1065
2
10-04-2012 03:40 AM
SaurabhDasgupta
Deactivated User
Hi,
  I am developing a silverlight solution to select my graphics object on the basemap from the Datagrid selection i.e., n selcting any row object on the datagrid the corresponding map graphics should be highlighted on the BaseMap. I following the below given code.

DataGrid dataGrid =  sender as DataGrid;
            GraphicsLayer selectedMapGraphics = edmsMap.Layers["selectionGraphicsLayer"] as GraphicsLayer;
            selectedMapGraphics.ClearGraphics();
           
            int selectedIndex = dataGrid.SelectedIndex;
            if (selectedIndex > -1)
            {               
                FindResult findResult = (FindResult)QueryDetailsDataGrid.SelectedItem;
                Graphic graphic = findResult.Feature;
                {
                    ESRI.ArcGIS.Client.Symbols.SimpleFillSymbol FillSymbol;
                    FillSymbol = (ESRI.ArcGIS.Client.Symbols.SimpleFillSymbol)(LayoutRoot.Resources["SelectSymbol"]);
                    graphic.Symbol = (ESRI.ArcGIS.Client.Symbols.Symbol)FillSymbol;
                    selectedMapGraphics.Graphics.Insert(0, graphic);
                }
                selectedMapGraphics.Graphics.Add(graphic);
            }   


But i am getting a exception in the following line of code.
FindResult findResult = (FindResult)QueryDetailsDataGrid.SelectedItem;

The error details are attached in the screen shot. Please let me know if anybody is having any solution to this particular exception  to resolve this.

~Saurabh.
0 Kudos
2 Replies
danielchaboya
Regular Contributor
0 Kudos
SaurabhDasgupta
Deactivated User
Hi Daniel,
           Thanks a lot for your reply. I have looked in the samples provided by you, but those have used same chunk of code that I am using and moreover I dont need anything like "zoom to" at this point of time. My concern is with the line of code

FindResult findResult = (FindResult)QueryDetailsDataGrid.SelectedItem;

which gives me the exception as provided in the screen shot. I need to rectify this exception to go ahead with the next line of code to get it executed. Any help will be greatly appreciated.

~Saurabh.
0 Kudos