AnsweredAssumed Answered

Select a markersymbol from code behind

Question asked by xaria on Jul 2, 2012
Latest reply on Jul 3, 2012 by xaria
Hi,

I have multiple points on a map which are represented with a markersymbol. Now from code behind on a certain event, the map pans to a particular point (x1,y1).
How do I get the markersymbol present at this point and mark it as selected??

EDIT:
So I have figured how to select the graphic at point. So far I have this
  <esriSymbols:SimpleMarkerSymbol x:Key="OrangeMarkerSymbol">
                <esriSymbols:SimpleMarkerSymbol.ControlTemplate>
                    <ControlTemplate>
                            <Grid Width="12" Height="12" x:Name="RootElement">
                                <VisualStateManager.VisualStateGroups>
                                    <VisualStateGroup x:Name="CommonStates">
                                        <VisualState x:Name="MouseOver">
                                        <Storyboard>
                                            <ColorAnimation BeginTime="00:00:00" Storyboard.TargetName="myrectangle" Storyboard.TargetProperty="(Rectangle.Stroke).(SolidColorBrush.Color)" To="Red" Duration="0:0:.25" />
                                            <DoubleAnimationUsingKeyFrames Storyboard.TargetName="myrectangle" Storyboard.TargetProperty="StrokeThickness" Duration="0:0:.5" RepeatBehavior="Forever">
                                                <LinearDoubleKeyFrame KeyTime="0" Value="3" />
                                                <LinearDoubleKeyFrame KeyTime="00:00:0.25" Value="1" />
                                                <LinearDoubleKeyFrame KeyTime="00:00:0.5" Value="3" />
                                            </DoubleAnimationUsingKeyFrames>
                                        </Storyboard>
                                    </VisualState>
                                    <VisualState x:Name="Normal" />
                                    </VisualStateGroup>
                                    <VisualStateGroup x:Name="SelectionStates">
                                        <VisualState x:Name="Selected">
                                            <Storyboard>
                                                <ColorAnimation BeginTime="00:00:00" Storyboard.TargetName="myrectangle" Storyboard.TargetProperty="(Rectangle.Stroke).(SolidColorBrush.Color)" To="Red" Duration="0:0:.25" />
                                                <DoubleAnimationUsingKeyFrames Storyboard.TargetName="myrectangle" Storyboard.TargetProperty="StrokeThickness" Duration="0:0:.5" RepeatBehavior="Forever">
                                                    <LinearDoubleKeyFrame KeyTime="0" Value="3" />
                                                    <LinearDoubleKeyFrame KeyTime="00:00:0.25" Value="1" />
                                                    <LinearDoubleKeyFrame KeyTime="00:00:0.5" Value="3" />
                                                </DoubleAnimationUsingKeyFrames>
                                            </Storyboard>
                                        </VisualState>
                                        <VisualState x:Name="Unselected" />
                                    </VisualStateGroup>
                                </VisualStateManager.VisualStateGroups>
                                <Rectangle x:Name="myrectangle" RadiusX="2" RadiusY="2" Fill="Gold" Cursor="Hand" Stroke="White" StrokeThickness="3" />
                            </Grid>
                   
                    </ControlTemplate>
                </esriSymbols:SimpleMarkerSymbol.ControlTemplate>
            </esriSymbols:SimpleMarkerSymbol>

And in the code behind
I have

MapPoint mPoint = new MapPoint(Convert.ToDouble(coordsX), Convert.ToDouble(coordsY));
                Point fPoint;
                GraphicsLayer grpLayer;
              
                    MyMap.PanTo(mPoint);
                    fPoint = MyMap.MapToScreen(mPoint);
                    GeneralTransform generalTransform = MyMap.TransformToVisual(Application.Current.MainWindow);
                    Point transformScreenPnt = generalTransform.Transform(fPoint);
                    grpLayer = MyMap.Layers["graphicsLayer"] as GraphicsLayer;
                    var selected = grpLayer.FindGraphicsInHostCoordinates(fPoint);

                    foreach (Graphic g in selected)
                    {
                        g.Selected = true;
                        return;
                    }                  
                }

Now even though I set the g.Selected to true, I cannot see the animation. What am I missing?

Outcomes