Select to view content in your preferred language

Clone Symbol

688
1
10-19-2011 06:39 AM
SteeveCouture
Emerging Contributor
Hello,

How can we clone a Symbol of graphic element?  I try to clone a MarkerSymbol but the graphic isn't display with the MarkerSymbol cloned.

This is my MarkerSymbol in xaml:
<esri:MarkerSymbol OffsetX="5.74" OffsetY="5.13335">
                <esri:MarkerSymbol.ControlTemplate>
                    <ControlTemplate>
                        <Grid RenderTransformOrigin="0.5,0.5" Width="11.48" Height="10.2667">
                            <Grid.RenderTransform>
                                <TransformGroup>
                                    <ScaleTransform ScaleX="1" ScaleY="1" />
                                </TransformGroup>
                            </Grid.RenderTransform>
                            <Canvas HorizontalAlignment="Left" VerticalAlignment="Top">
                                <Path Fill="#00FFFFFF" Stroke="Black" StrokeThickness="1" Data="F1 M 1.12181e-007,10.2667L 5.84208,0L 11.48,10.2667L 1.12181e-007,10.2667 Z " />
                            </Canvas>
                        </Grid>
                    </ControlTemplate>
                </esri:MarkerSymbol.ControlTemplate>
            </esri:MarkerSymbol>


This is my code to clone:

MarkerSymbol newMarkerSymbol = new MarkerSymbol();
                newMarkerSymbol.ControlTemplate = oldMarkerSymbol.ControlTemplate;
                newMarkerSymbol.OffsetX = oldMarkerSymbol.OffsetX;
                newMarkerSymbol.OffsetY = oldMarkerSymbol.OffsetY;


Thanks,
Steeve
0 Kudos
1 Reply
DominiqueBroux
Esri Frequent Contributor
I don't see any mistake in your code.

It might happen that your symbol is not just a MarkerSymbol but a sub class of markerSymbol such as SimpleMarkerSymbol.

In this case your code doesn't initialize the additional properties of the subclass (such as Color for a SimpleMarkerSymbol).

That being said, your symbol defined in XAML is a pure MarkerSymbol, so your code should work.
0 Kudos