Change selection color of graphics layer

2386
2
06-24-2012 08:37 PM
EdwardSon
Emerging Contributor
Is it possilbe to easily change selection color of graphics layer?
Feature layer has SelectionColor property but graphics layer does not.
Is there an easy or best way to accomplish this?
0 Kudos
2 Replies
DominiqueBroux
Esri Frequent Contributor
You are right, unfortunately GraphicsLayer has no SelectionColor property.

The way to do it is by defining your own symbols with 'Selected' selectionStates.

As sample, here is how the X feature symbol is defined:
 
    <ControlTemplate x:Key="FS_SimpleMarkerSymbol_X">
        <Path x:Name="Ex"
              Stretch="Fill"
              Data="M0,1 L1,0 2,1 3,0 4,1 3,2 4,3 3,4 2,3 1,4 0,3 1,2 Z"
              Width="{Binding Symbol.Size}"
              Height="{Binding Symbol.Size}"
              RenderTransformOrigin="{Binding Symbol.RenderTransformPoint}"
              Fill="{Binding Symbol.Color}"
              Stroke="{Binding Symbol.OutlineColor}"
              StrokeThickness="{Binding Symbol.OutlineThickness}"
              StrokeDashArray="{Binding Symbol.OutlineStyle, Converter={StaticResource DashArrayConverter}}"
              StrokeLineJoin="Round">
            <Path.RenderTransform>
                <RotateTransform Angle="{Binding Symbol.Angle}"/>
            </Path.RenderTransform>
            <VisualStateManager.VisualStateGroups>
                <VisualStateGroup x:Name="SelectionStates">
                    <VisualState x:Name="Unselected" />
                    <VisualState x:Name="Selected">
                        <Storyboard>
                            <ObjectAnimationUsingKeyFrames Storyboard.TargetName="Ex"
                                Storyboard.TargetProperty="Fill">
                                <DiscreteObjectKeyFrame KeyTime="0:0:0" Value="{Binding Symbol.SelectionColor}" />
                            </ObjectAnimationUsingKeyFrames>
                        </Storyboard>
                    </VisualState>
                </VisualStateGroup>
            </VisualStateManager.VisualStateGroups>
        </Path>
    </ControlTemplate>
0 Kudos
EdwardSon
Emerging Contributor
You wouldn't happen to have one for rectangle would you...?

That would be great...
0 Kudos