A few questions/issues (mostly around FeatureLayer)

2143
2
08-31-2011 05:16 PM
Labels (1)
RyanCoodey
Occasional Contributor III
A few questions and issues:

1) Issue: After selecting (in code via graphic.Select()) several points (symbol is red circle with black outline) the features on the screen are selected (with the light blue fill).  But any features off the screen when panned to have a hollow fill.  Also a feature that was selected fine at first, when panned off the screen and back on, will then be hollow as well.  Any ideas?

2) What is the best way on mouse over of a feature (in a FeatureLayer) to slightly enlarge the symbol size (selected or not)?  Just to show the user it has the mouse over focus... I don't want to change the symbol provided by the service though by overriding the whole Symbol Control Template.

3) Is there a way to set the selected graphics to have a higher Z order, to be on top of other non-selected features?
*Update* Currently I control this by using SetZIndex() in custom select/unselect methods to make the Z index either 1 or 0 respectively, but this doesn't work if these methods are not used. Since SelectedGraphics doesn't have a CollectionChanged event, not sure if there is a better way?

4) Issue: This is a temperamental issue that is true with all Layer types; We have a loading bar on the screen until Map.Layers.LayersInitialized is called, then the loading bar is closed in the event handler.  Well, sometimes this event is never fired, but neither is layer.InitializationFailed (which is set on each layer in Map.Layers)... so the loading bar never closes.  Is there a bug here?  Is there a better way to implement this?

Thanks a lot for any help!
0 Kudos
2 Replies
JenniferNery
Esri Regular Contributor
A few questions and issues:

1) This bug has been fixed for the next release of the API.

2) If you want to scale the graphic symbol on mouse hover, you have to override the Symbol's ControlTemplate and include VisualState for selection. You can look at this SDK sample: http://help.arcgis.com/en/webapi/silverlight/samples/start.htm#CustomSymbols. You can still copy the same symbol properties defined by your service but you need to use client symbol to be able to update its ControlTemplate.


3) Yes, you can use SetZIndex on the graphic. You can subscribe to Layer.PropertyChanged and watch for SelectionCount or SelectedGraphics property so you can update graphic ZIndex, you might need to use Linq to separate graphics that are not selected. If you are using Editor.Select, Editor.EditCompleted event will have a list of affected graphics in e.Edits, you can simply check edit.Graphic.Selected property.

4) Can you send us code/steps to reproduce? I'm not sure what to tell you about this sorry.
0 Kudos
RyanCoodey
Occasional Contributor III
Thanks for all the info Jennifer!

Good to know on number 1 and I got number 3 worked out...

Still working on number 2; I am looping through each graphic trying to change it's Symbol.ControlTemplate.  I understand how the VisualStates work, but not real sure how to copy a ControlTemplate and inject a VisualState into it.... also, the Symbol needs a ScaleTransform, how do I inject that?

Here are a few things I was trying but don't work:
                DependencyObject symbolDependencyObject = graphic.Symbol.ControlTemplate.LoadContent();
                FrameworkElement symbolFrameworkElement = symbolDependencyObject as FrameworkElement;

                symbolFrameworkElement.RenderTransform = new ScaleTransform(50, 50); //Scaling big initially just to see if scale works

                var storyboard = new Storyboard();
                var doubleAnimation = new DoubleAnimation(50, 1, new Duration(TimeSpan.Zero));
                Storyboard.SetTarget(doubleAnimation, symbolFrameworkElement);
                Storyboard.SetTargetProperty(doubleAnimation, new PropertyPath("RenderTransform.ScaleX"));
                storyboard.Children.Add(doubleAnimation);

                var storyboard2 = new Storyboard();
                var doubleAnimation2 = new DoubleAnimation(1, 50, new Duration(TimeSpan.Zero));
                Storyboard.SetTarget(doubleAnimation2, symbolFrameworkElement);
                Storyboard.SetTargetProperty(doubleAnimation2, new PropertyPath("RenderTransform.ScaleX"));
                storyboard2.Children.Add(doubleAnimation2);

                var stateGroup = new VisualStateGroup { Name = "MouseOverState" };
                stateGroup.States.Add(new VisualState { Name = "MouseOut", Storyboard = storyboard });
                stateGroup.States.Add(new VisualState { Name = "MouseOver", Storyboard = storyboard2 });

                var sgs = VisualStateManager.GetVisualStateGroups(symbolFrameworkElement);
                sgs.Add(stateGroup);


I also tried just adding a trigger, but again do not have a ScaleTransform plus it throws this error "After a 'TriggerCollection' is in use (sealed), it cannot be modified.", so guess this is a no go.
                Trigger trigger = new Trigger();
                trigger.Property = FrameworkElement.IsMouseOverProperty;
                trigger.Value = true;
                Setter setter = new Setter();
                setter.Property = ScaleTransform.ScaleXProperty;
                setter.Value = 50;
                trigger.Setters.Add(setter);
                graphic.Symbol.ControlTemplate.Triggers.Add(trigger);


Still poking around this code, but any help or ideas would be great!  Thanks!

And with number 4, there really isn't anything special with the code; the map is referencing some internal services and some ESRI services.  It has something to do with our network here I think.  When ESRI started using the Amazon cloud, it dynamically routes traffic so services.arcgisonline.com will give different IPs.  Some of these IPs were in our routers block list, after allowing them this hanging of the layers loading went down drastically.  It still happens every once in a while (a lot yesterday though) and I think it now is some issue with our proxy.  I have our network guys looking into it (kind of hard though since it is temperamental).  Anyway, I guess the only question I have is if there is a way to set/control the timeout of a layer?  Maybe I can set it to give up after 15 seconds or something?   So at least other layers can then load.

Thanks a ton for all your great help!
0 Kudos