I have an app that builds a set of ESRI.ArcGIS.Client.Graphic objects based on the results of searching a Geoportal. The graphics are displayed as rectangles which represent the extents of the data that was found in the search. The extent rectangles often overlap each other and are of various sizes. The goal is to order the graphic rectangles such that the smallest ones overlay the larger rectangles. Think of it as ordering various sized pieces of paper from smallest to largest.The app currently works fine running under the full Silverlight API and I am in the process of porting it to the Silverlight Viewer 3.1.The problem I am encountering in the Silverlight viewer is that I cannot maintain the order of the graphics on the graphics layer.In the full Silverlight API I solved this by computing the area of each rectangle and then performing a descending sort on a list of the graphics.
internal class RssGraphic : Graphic
{
//DLG June 13, 2011 - Builds an object with the following fields. Note that it is inheriting from the the ESRI class 'Graphic'.
//DLG July 5, 2011 - Add a property named ExtentArea. This is used to sort a list of these objects.
public Dictionary<string, object> RssAttributes { get; set; }
public string StringPolygon { get; set; }
public string title { get; set; }
public string Description { get; set; }
public double ExtentArea { get; set; }
public ESRI.ArcGIS.Client.Geometry.Polygon poly { get; set; }
}
List<RssGraphic> rssGraphics = new List<RssGraphic>();
//Do work to populate rssGraphics
List<RssGraphic> rssGraphics_Sorted_ExtentArea = new List<RssGraphic>();
IEnumerable<RssGraphic> rssGraphicsEnum_ExtentArea = from g in rssGraphics orderby g.ExtentArea descending select g;
foreach (RssGraphic g in rssGraphicsEnum_ExtentArea)
{
rssGraphics_Sorted_ExtentArea.Add(g);
}
foreach (RssGraphic graphic in rssGraphics_Sorted_ExtentArea)
{
//do a bunch of work
_graphicsLyr.Graphics.Add(graphic);
}
The result is that the rectangles are sorted largest to smallest (bottom to top) and get stacked in the graphics layer such that the smallest rectangles are at the top and can always be queried via a mouse click. Click events are assigned to each graphic.In the full Silverlight API this has consistently worked for several years.However, in the Silverlight Viewer the sorting works on the very first search but then never again until the app is restarted. The code behind is still performing the search correctly and when I examine the graphics layer the graphic objects are in fact sorted. However, after the first search operation, subsequent searches result in the largest rectangle always being on top of the smaller ones and I can no longer access the click events of the underlying graphic objects. I'm at the point of believing there is a bug in the viewer.Has anyone else encountered this and been able to fix it?Dennis GeasanGIS Technologies