Select to view content in your preferred language

Using standard apperance of SimpeFillSymbol

1590
4
Jump to solution
10-31-2012 07:56 AM
JohanCarlsson
Regular Contributor
Hi!

I'm loading objects in a shape file and looping through them, adding them to the map with this FillSymbol:

            ESRI.ArcGIS.Client.Symbols.SimpleFillSymbol ImportFillSymbol = new ESRI.ArcGIS.Client.Symbols.SimpleFillSymbol();             ImportFillSymbol.Fill = new System.Windows.Media.SolidColorBrush(System.Windows.Media.Color.FromArgb(255, 128, 0, 255));             ImportFillSymbol.BorderBrush = new System.Windows.Media.SolidColorBrush(System.Windows.Media.Color.FromArgb(255, 79, 0, 157));             ImportFillSymbol.BorderThickness = 1;


Everything works fine except that selected items don't have a separate FillSymbol for selection so you can't see which objects you've selected. If I go into the default "Configure Layer" and change the symbology to one of the standard FillSymbols, the selection works fine. So my question is simple:

Is there a a way of accessing these standard FillSymbols? Simply something like this:

SimpleFillSymbol ImportFillSymbol = AlreadyDefinedFillSymbol.Red


Thanks for your time.

Johan Carlsson
0 Kudos
1 Solution

Accepted Solutions
deleted-user-ATjHIWsdQYmT
Deactivated User
Are you using the ArcGIS Viewer for the Silverlight?  If so, this is foreign territory for me.  You might want to post over in that forum.
http://forums.arcgis.com/forums/211-ArcGIS-Viewer-for-Silverlight

Can you access the event handlers of your graphics layer?  If so you can handle something like the MouseEnter event and change the symbology.  Then swap it back on the MouseLeave event.  I didn't try MouseLeave, but here's some code for MouseEnter (sorry, VB...)
 Private Sub GraphicsLayer_MouseEnter(sender As System.Object, e As ESRI.ArcGIS.Client.GraphicMouseEventArgs)         Dim gr As New Graphic         gr = e.Graphic         Dim sy As New SimpleFillSymbol         sy.Fill = New Media.SolidColorBrush(Media.Color.FromArgb(128, 254, 0, 0))         gr.Symbol = sy       End Sub

View solution in original post

0 Kudos
4 Replies
deleted-user-ATjHIWsdQYmT
Deactivated User
Are you loading your Shapefile features into a GraphicsLayer?
If so, check out this sample:
http://resources.arcgis.com/en/help/silverlight-api/samples/start.htm#SelectGraphics

You can define your "Selected" and "Unselected" feature symbology in your XAML:
<esri:FillSymbol x:Key="SelectFillSymbol">
                <esri:FillSymbol.ControlTemplate>
                    <ControlTemplate>
                        <Path x:Name="Element"
       Stroke="Black"
       StrokeStartLineCap="Round"
       StrokeThickness="2"
       StrokeLineJoin="Round"
       StrokeEndLineCap="Round" 
       Fill="Blue">
                            <VisualStateManager.VisualStateGroups>
                                <VisualStateGroup x:Name="SelectionStates">
                                    <VisualState x:Name="Unselected" >
                                        <Storyboard>
                                            <ColorAnimation Storyboard.TargetName="Element" 
           Storyboard.TargetProperty="(Path.Fill).(SolidColorBrush.Color)"
           To="Blue"  Duration="00:00:00.25"/>
                                        </Storyboard>
                                    </VisualState>
                                    <VisualState x:Name="Selected">
                                        <Storyboard>
                                            <ColorAnimation Storyboard.TargetName="Element" 
           Storyboard.TargetProperty="(Path.Fill).(SolidColorBrush.Color)"
           To="Cyan" Duration="00:00:00.25"/>
                                            <ObjectAnimationUsingKeyFrames Storyboard.TargetName="Element" Storyboard.TargetProperty="StrokeDashArray">
                                                <DiscreteObjectKeyFrame KeyTime="0:0:0">
                                                    <DiscreteObjectKeyFrame.Value>
                                                        <DoubleCollection>2,1</DoubleCollection>
                                                    </DiscreteObjectKeyFrame.Value>
                                                </DiscreteObjectKeyFrame>
                                            </ObjectAnimationUsingKeyFrames>
                                        </Storyboard>
                                    </VisualState>
                                </VisualStateGroup>
                            </VisualStateManager.VisualStateGroups>
                        </Path>
                    </ControlTemplate>
                </esri:FillSymbol.ControlTemplate>
            </esri:FillSymbol>


0 Kudos
JohanCarlsson
Regular Contributor
Thanks for your reply Andrew.

This tool doesn't have an associated XAML file, is it possible to add one at another location?
I've tried removing the fills that I've defined myself and loading the graphics onto the GraphicsLayer without it. Then the default style is transparent with a black border. This style works just fine to mark as selected although they are too hard to see when zoomed out at certain layers when they are not selected.

If I add graphics to a new layer an choose any of these predefined symbols, I get the selected style "for free" without having to define it in any xaml or code behind. I've added a picture to expalin which symbols I mean.
0 Kudos
deleted-user-ATjHIWsdQYmT
Deactivated User
Are you using the ArcGIS Viewer for the Silverlight?  If so, this is foreign territory for me.  You might want to post over in that forum.
http://forums.arcgis.com/forums/211-ArcGIS-Viewer-for-Silverlight

Can you access the event handlers of your graphics layer?  If so you can handle something like the MouseEnter event and change the symbology.  Then swap it back on the MouseLeave event.  I didn't try MouseLeave, but here's some code for MouseEnter (sorry, VB...)
 Private Sub GraphicsLayer_MouseEnter(sender As System.Object, e As ESRI.ArcGIS.Client.GraphicMouseEventArgs)         Dim gr As New Graphic         gr = e.Graphic         Dim sy As New SimpleFillSymbol         sy.Fill = New Media.SolidColorBrush(Media.Color.FromArgb(128, 254, 0, 0))         gr.Symbol = sy       End Sub
0 Kudos
JohanCarlsson
Regular Contributor
Oh, sorry about that, I didn't see that forum. Yes, I'm using the viewer.
No problem with VB, the functionality is still easy to see and convert 🙂
It solved the problem though and now works for every layer and with the attribute table.

Thank you!
0 Kudos