Multiple Controls (views), single GraphicsLayer and symbol problem

1422
1
12-03-2012 08:23 AM
by Anonymous User
Not applicable
Original User: Steve Clark

I have a SL application (actually a SL Viewer Add-In for now) that has multiple controls (all different locators) but supposedly accessing a single graphicslayer. Users can switch from one control to another and I want the graphicslayer to clear no matter if they are in the same control or a different one. The problem appears to be that each control has its own graphicslayer and switching views loses its scope.

Here's what I have in each control:

            <esri:SimpleMarkerSymbol x:Name="LocationSymbol" Color="Red" Size="12"/>
            <esri:GraphicsLayer x:Key="ResultsLayer" ID="MatchCandidatesLayer">
                <esri:GraphicsLayer.Renderer>
                    <esri:SimpleRenderer Symbol="{StaticResource LocationSymbol}" />
                </esri:GraphicsLayer.Renderer>
            </esri:GraphicsLayer>


in each of the button, I have the following triggers:

 
            <views:AddLayerAction TargetObject="{Binding Map}" 
                             Layer="{StaticResource ResultsLayer}" />
            <models:CandidatesToGraphicsAction MatchCandidates="{Binding MatchCandidates}"
                             MatchGraphics="{Binding MatchGraphics, Mode=TwoWay}" />
            <esri:ClearGraphicsAction GraphicsLayerID="MatchCandidatesLayer" 
                             TargetObject="{Binding Map}" />
            <viewmodels:AddGraphicsAction TargetObject="{StaticResource ResultsLayer}"
                             Graphics="{Binding MatchGraphics}" />


If I stay in one view, it seems to clear upon a new resultslayer but not if I switch to another view. There is no property change on the graphicslayer that I can see so how does one ensure that the graphics from the previous results are always cleared?

Along the same line, my second question has to do with binding the graphics symbol. In other controllers, I use a different TriggerAction to turn the results (list of a custom object) into graphics but same pattern as the address above:

 
            <views:AddLayerAction TargetObject="{Binding Map}" 
                                        Layer="{StaticResource ResultsLayer}" />
             <models:SpatialResultsToGraphicsAction SpatialResults="{Binding SpatialResults}"
                                        MatchGraphics="{Binding MatchGraphics, Mode=TwoWay}" />
             <esri:ClearGraphicsAction GraphicsLayerID="MatchCandidatesLayer" 
                                        TargetObject="{Binding Map}" />
             <viewmodels:AddGraphicsActionGS TargetObject="{StaticResource ResultsLayer}"
                                        Graphics="{Binding MatchGraphics}" />


I can't seem to get the graphics symbol ("LocationSymbol") to bind to the resulting graphics even though I did veryify that the coordinates are good (I can zoom to the extent of the graphics with no problems). What am I missing on binding the symbol?
0 Kudos
1 Reply
DominiqueBroux
Esri Frequent Contributor
There is no property change on the graphicslayer that I can see so how does one ensure that the graphics from the previous results are always cleared?


Did you try to subscribe to GraphicsLayer.Graphics.CollectionChanged event?
0 Kudos