Select to view content in your preferred language

How to change the SimpleRenderer ControlTemplate using code behind ?

2151
1
02-28-2014 06:43 PM
AdamAnand
Deactivated User
Hello Team,

I have few "Graphics Layers" in my map control.

When "Graphics" is selected from 1st Graphics Layer it should be highlighted in "Red" color.
When "Graphics" is selected from 2nd Graphics Layer it should be highlighted in "Blue" color.
When "Graphics" is selected from 3rd Graphics Layer it should be highlighted in "Green" color.

How can I achieve this using the "ControlTemplate" inside "SimpleRenderer" in the XAML file ?

Should I have to declare one "SimpleRenderer" for each Graphics Layer ? Please advise.

Can I change the "Selection Color" somehow in the code behind .cs  file ? Any help is appreciated.

Thank you for your time.

Thanks
Adam
0 Kudos
1 Reply
DominiqueBroux
Esri Frequent Contributor
Hello Team,

I have few "Graphics Layers" in my map control.

When "Graphics" is selected from 1st Graphics Layer it should be highlighted in "Red" color.
When "Graphics" is selected from 2nd Graphics Layer it should be highlighted in "Blue" color.
When "Graphics" is selected from 3rd Graphics Layer it should be highlighted in "Green" color.

How can I achieve this using the "ControlTemplate" inside "SimpleRenderer" in the XAML file ?

Should I have to declare one "SimpleRenderer" for each Graphics Layer ? Please advise.

Can I change the "Selection Color" somehow in the code behind .cs  file ? Any help is appreciated.

Thank you for your time.

Thanks
Adam


You are right, you have to declare one SimpleRenderer for each graphic layer with a symbol that you can declare in XAML with a 'selection' state.
Something like:

<ControlTemplate>
    <Ellipse x:Name="ellipse"
                Fill="{Binding Symbol.Color}"
                Width="{Binding Symbol.Size}"
                Height="{Binding Symbol.Size}"
                Stroke="Black"
                StrokeThickness="1"
                >
        <Ellipse.Resources>
            <Storyboard x:Key="SelectionAnimation">
                <ObjectAnimationUsingKeyFrames Storyboard.TargetName="ellipse"
                                                Storyboard.TargetProperty="Fill">
                    <DiscreteObjectKeyFrame KeyTime="0:0:0"
                                            Value="Red" />
                </ObjectAnimationUsingKeyFrames>
            </Storyboard>
        </Ellipse.Resources>
        <vsm:VisualStateManager.VisualStateGroups>
            <vsm:VisualStateGroup x:Name="SelectionStates">
                <vsm:VisualState x:Name="Unselected" />
                <vsm:VisualState x:Name="Selected"
                                    Storyboard="{StaticResource SelectionAnimation}" />
            </vsm:VisualStateGroup>
        </vsm:VisualStateManager.VisualStateGroups>
    </Ellipse>
</ControlTemplate>
0 Kudos