okachirski

Selected visual state of Graphics malfunctions after upgrade 2.1 to 2.2 API

Discussion created by okachirski on Jul 29, 2011
Latest reply on Aug 1, 2011 by okachirski
I have a polygon layer symbolized based on Selected state of Graphics. The XAML definition (straight from ESRI samples) is below.
<esri:SimpleRenderer x:Key="SelectFillSymbol">
        <esri:SimpleRenderer.Symbol>
            <esri:FillSymbol>
                <esri:FillSymbol.ControlTemplate>
                    <ControlTemplate>
                        <Path x:Name="Element"
       Stroke="Black"
       StrokeStartLineCap="Round"
       StrokeThickness="1.5"
       StrokeLineJoin="Round"
       StrokeEndLineCap="Round" 
       Fill="#00FFFFFF">
                            <VisualStateManager.VisualStateGroups>
                                <VisualStateGroup x:Name="SelectionStates">
                                    <VisualState x:Name="Unselected" >
                                        <Storyboard>
                                            <ColorAnimation Storyboard.TargetName="Element" 
           Storyboard.TargetProperty="(Path.Fill).(SolidColorBrush.Color)"
           To="#00FFFFFF"  Duration="00:00:00.25"/>
                                        </Storyboard>
                                    </VisualState>
                                    <VisualState x:Name="Selected">
                                        <Storyboard>
                                            <ColorAnimation Storyboard.TargetName="Element" 
           Storyboard.TargetProperty="(Path.Fill).(SolidColorBrush.Color)"
           To="#44AA00FF" 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>
                                <VisualStateGroup x:Name="CommonStates">
                                    <VisualState x:Name="Normal" />
                                </VisualStateGroup>
                            </VisualStateManager.VisualStateGroups>
                        </Path>
                    </ControlTemplate>
                </esri:FillSymbol.ControlTemplate>
            </esri:FillSymbol>
        </esri:SimpleRenderer.Symbol>
    </esri:SimpleRenderer>


I load the indices of the Graphic objects that need to be selected, and select the appropriate graphics at the beginning, like so:

MyGraphicsLayer.Graphics.Where<Graphic>(sector => MySelectedList.Contains(int.Parse(sector.Attributes["SectorID"].ToString())))
                .ToList<Graphic>().ForEach(g => { if (!g.Selected) g.Select(); });


This selects all Graphics in the layer, which SectorID attribute is in the MySelectedList List<int>. It was working fine in WPF 2.1 API, however, after upgrading to 2.2 API, the selected graphics on the map do not update their representation to selected (layer refresh does not help). Only when I start mousing over the polygons, those graphics that are selected start changing the look, and only when the mouse cursor passes over each individual polygon. I don't have any mouseover events on that layer or the map in general.

ESRI - thank you for looking into this.

Outcomes