Select to view content in your preferred language

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

1094
2
07-29-2011 04:03 AM
Labels (1)
OlegKachirski
Occasional Contributor
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.
0 Kudos
2 Replies
JenniferNery
Esri Regular Contributor
Can you verify in debug mode if these features are selected? GraphicsLayer.SelectedGraphics is not empty, GraphicsLayer.SelectionCount is greater than zero, and those specific graphics have Graphic.Selected = true? If yes, then the issue is with applying visual state. Are you using GraphicsLayer or FeatureLayer? If you are using FeatureLayer, does OutFields contain "SectorID" field? If you are using GraphicsLayer, does your Query.OutFields include "SectorID"? You can verify that graphic.Attributes contain this field, also check that you cast it to the proper data type.
0 Kudos
OlegKachirski
Occasional Contributor
Jennifer,

Yes, the graphics are indeed selected. I've filed a ticket - Esri Incident #951394.

Thanks.
0 Kudos