Bug in FeatureDataGrid 3.0 with Silverlight 4

403
8
12-18-2012 12:18 PM
HyrumErnstrom
New Contributor III
Any one else have an issue with the FeatureDataGrid 3.0 in Silverlight 4?

We have the FeatureDataGrid set to a GraphicsLayer that we clear and populate with new "Selected Graphics". Basically a query to the server on a single layer that adds to the GraphicsLayer.

The code is built in Silverlight 4 and works fine in Silverlight 5 but when ran in Silvelright 4 it gets a null value exceptions.

After debugging the code it appear to be in the following line of code:

FeatureDataGrid.Silverlight.cs line ~394

  
var enumerableGraphics = graphics.ToDataSource(fieldInfo, rangeDomainInfo, fieldProps, uniqueID, FilterSource, out objectType) as IEnumerable<object>;


the graphics.ToDataSource returns a IEnumerable but when it gets cast to IEnumberable<object> it returns null;

So I fixed it with the following.

         ///Fixes for Silverlight 4
            var enumerableGraphics = graphics.ToDataSource(fieldInfo, rangeDomainInfo, fieldProps, uniqueID, FilterSource, out objectType).AsList();

Reply
0 Kudos
8 Replies
AnastasiaAourik
New Contributor II
I too am having problems since upgrading to FeatureDataGrid 3.0.
I'm not quite clear on what you are doing:

I have this in my xaml:
                            <esriToolkit:FeatureDataGrid x:Name="resultFeatureDataGrid"
                                MinHeight="200" MaxHeight="400" Margin="5" GridLinesVisibility="All" HeadersVisibility="All" ClipboardCopyMode="IncludeHeader"
                                HorizontalAlignment="Stretch" VerticalAlignment="Stretch" AutoGenerateColumns="True"
                                Map="{Binding ElementName=Map}"
                                GraphicsLayer="{Binding Layers.[MyGraphicsLayer], ElementName=Map}"
                                RowStyle="{StaticResource DataGridRowStyle1}" />


MyGraphicsLayer gets filled with a QueryExecuteTaskComplete from the args.FeatureSet..

I would clear the MyGraphicsLayer and then loop through Features in Featureset and do
graphicsLayer.Graphics.Add(graphic)

But this does not work any longer.
Reply
0 Kudos
DominiqueBroux
Esri Frequent Contributor
Could you share a sample allowing to reproduce the issue?
Thanks
Reply
0 Kudos
ChrisTallman
New Contributor III
I am also seeing a bug with the feature data grid.  It seems similar to AnastasiaAourik is talking about, however I think the issue has to do with the "throttler" Dispatch Timer that was added.  I think the issue is in the code below:
void DispatcherTimer_Tick(object sender, EventArgs e)
     {
       if (startTime != null && (DateTime.Now.Ticks - startTime.Ticks) >= 500)
       {
         throttler.Stop();
         // Synchronizing selections in current DataGrid's page and the associated GraphicsLayer:
         RestorePreviousSelection(GraphicsLayer.SelectedGraphics);     
       }     
     }

I think the issue is if the GraphicsLayer has been cleared the process is throwing a null ref exception.  I could be wrong, but this is where I'm getting an error and it has to do with a null ref exception in the DispatcherTimer_Tick event right after I clear the graphics layer that is bound to the grid.

Chris
Reply
0 Kudos
ChrisTallman
New Contributor III
Downloading the toolkit source I changed this section of code:

void DispatcherTimer_Tick(object sender, EventArgs e)
{
if (startTime != null && (DateTime.Now.Ticks - startTime.Ticks) >= 500)
{
  throttler.Stop();
  // Synchronizing selections in current DataGrid's page and the associated GraphicsLayer:
         RestorePreviousSelection(GraphicsLayer.SelectedGraphics);  
}  
}


To this and my issue went away.  This is in the FeatureDataGrid.Silverlight.cs file.

void DispatcherTimer_Tick(object sender, EventArgs e)
{
if (startTime != null && (DateTime.Now.Ticks - startTime.Ticks) >= 500)
{
  throttler.Stop();
  // Synchronizing selections in current DataGrid's page and the associated GraphicsLayer:
                if (GraphicsLayer != null)
       RestorePreviousSelection(GraphicsLayer.SelectedGraphics);  
}  
}
Reply
0 Kudos
AnastasiaAourik
New Contributor II
Dominque,

Can you confirm if this is the case.
I really don't want to change the API source so do you have another solution or can you tell me if a patch is coming shortly.

Thanks,aa
Reply
0 Kudos
AnastasiaAourik
New Contributor II
Exception I get is:

at System.Linq.Enumerable.Count[TSource](IEnumerable`1 source)
   at ESRI.ArcGIS.Client.Toolkit.FeatureDataGrid.SetItemsSource(IEnumerable`1 graphics)
   at ESRI.ArcGIS.Client.Toolkit.FeatureDataGrid.UpdateItemsSource(Object sender, NotifyCollectionChangedEventArgs e)
   at ESRI.ArcGIS.Client.Toolkit.FeatureDataGrid.Graphics_CollectionChanged(Object sender, NotifyCollectionChangedEventArgs e)
   at System.Collections.Specialized.NotifyCollectionChangedEventHandler.Invoke(Object sender, NotifyCollectionChangedEventArgs e)
   at System.Collections.ObjectModel.ObservableCollection`1.OnCollectionChanged(NotifyCollectionChangedEventArgs e)
   at System.Collections.ObjectModel.ObservableCollection`1.InsertItem(Int32 index, T item)
   at ESRI.ArcGIS.Client.GraphicCollection.InsertItem(Int32 index, Graphic item)
   at System.Collections.ObjectModel.Collection`1.Add(T item)
   at WellsGisLocal.MainPage.doSpatialSearch_QueryTask_WELLS_ExecuteCompleted(Object sender, QueryEventArgs args)

I get this exception at this code line (when I am adding a Graphic to the GraphicLayer 'MyGraphicsLayer', which is a special layer that holds search results in my application.

                        graphicsLayer.Graphics.Add(selectedFeature);

My XAML has this:
                            <esriToolkit:FeatureDataGrid x:Name="resultFeatureDataGrid"
                                MinHeight="200" MaxHeight="400" Margin="5" GridLinesVisibility="All" HeadersVisibility="All" ClipboardCopyMode="IncludeHeader"
                                HorizontalAlignment="Stretch" VerticalAlignment="Stretch" AutoGenerateColumns="True"
                                Map="{Binding ElementName=Map}" BindingValidationError="resultFeatureDataGrid_BindingValidationError"
                                GraphicsLayer="{Binding ElementName=Map, Path=Layers.[MyGraphicsLayer]}"
                                RowStyle="{StaticResource DataGridRowStyle1}" />

It used to work that when I populate MyGraphicsLayer with results from a QueryTask (looping through featureSet)
FeatureDataGrid that is bound to Map for Layers.[MyGraphicsLayer] would automatically populate, and since upgrading to
FeatureDataGrid3 (via the new ArcGIS Silverlight API) it no longer works.
Reply
0 Kudos
AnastasiaAourik
New Contributor II
Okay, I've learned a bit...
It is true that FEATUREDATAGRID3, that comes with the arcgis api version 3 does not work with Silverlight 4.
[Infact, it stopped working since arcgis api 2.4)
Now, when we say Silveright 4, we don't mean the 'runtime' that is an add-on to your browswer.
We mean the Silverlight_Developer and Silverlight_Toolkit (and optionally ExpressionBlend stuff) that constitutes the Silverlight controls that you will have as references in your Visual Studio 2010 project.

Proof:
http://help.arcgis.com/en/webapi/silverlight/samples/start.htm#FeatureDataGrid
(these sampes are using arcgis api 2.4)
Look at the FeatureDataGrid sample on Toolkit Controls from above link.
It does not work (even if your runtime is Silverlight 5) because the application was built with the wrong combination of arcgis api and silverlight developer api.

So if you have featuredatagrid3 in your own custom application
You must install (upgrade all the silverlight items) that are required for Arcgsi api 3.0 (see installations page)
http://resources.arcgis.com/en/help/silverlight-api/concepts/index.html#/Installation/01660000000500...

And you MUST target the correct version of Silverlight in your Visual Studio project.
Reply
0 Kudos
DaveOrlando
Occasional Contributor III
if this is the case, it would be kind of ESRI to report this as a breaking change for Silverlight 4.

also, if you've been using VS2010, plan to upgrade to VS2013, because (as stated in the link above) 'Blend Preview is no longer available, use blend with VS2012 SP2+ or VS2013' (to get 'Microsoft.Expression.Interactions back)


fun times
Reply
0 Kudos