ArcGIS API for Windows Phone - Library Reference
Symbol Property
See Also  Example Send comments on this topic
ESRI.ArcGIS.Client Namespace > Graphic Class : Symbol Property

Gets or sets the Symbol used for rendering the Graphic.

Syntax

Visual Basic (Declaration) 
Public Property Symbol As Symbol
C# 
public Symbol Symbol {get; set;}

Remarks

In order to display a Graphic on the Map, a Symbol must be associated with each Graphic. A Graphic’s Geometry Property must match the Symbol type. This means a MarkerSymbol for a MapPoint or MultiPoint, FillSymbol for a Polygon, and LineSymbol for a Polyline.

Example

How to use:

Click the button to select every other Graphic and then change the Symbol of the selected Graphics to one that was defined in XAML.

The XAML code in this example is used in conjunction with the code-behind (C# or VB.NET) to demonstrate the functionality.

The following screen shot corresponds to the code example in this page.

Selecting every other Graphic and changing its Symbol.

XAMLCopy Code
<Grid x:Name="LayoutRoot">
  
  <!-- Define two SimpleMarkerSymbol's and a SpatialReference in the Resources section of the XAML file. -->
  <Grid.Resources>
  
    <!-- Tip: Use x:Key Attribute and not x:Name Attribute for defining the name of the Resources so that
         you can access the Resource in the code-behind file. -->
  
    <!-- The 'RedMarkerSymbol' will be used as the default symbol for the Graphics. -->
    <esri:SimpleMarkerSymbol x:Key="RedMarkerSymbol" Color="Red" Size="12" Style="Circle" />
    
    <!-- The 'SelectedMarkerSymbol' will be used in the code-behind file to change the symbology
         for the Selected Graphics. -->
    <esri:SimpleMarkerSymbol x:Key="SelectedMarkerSymbol" Color="Black" Size="14" Style="Diamond" />
    
    <!-- Define a SpatialReference object that has the same WKID as the ArcGISTiledMapServiceLayer in
         the Map. This will allow for the Graphics in the GraphicsLayer to line up properly. -->
    <esri:SpatialReference x:Key="theSpatialReference" WKID="102100"/>
    
  </Grid.Resources>
  
  <!-- Add a Map control with an ArcGISTiledMapServiceLayer and a GraphicsLayer. The GraphicsLayer will
       contain several Graphics based upon MapPoint geometries (which use the defined SpatialReference) 
       and using the RedMarkerSymbol as the default symbolization. -->
  <esri:Map Background="White" HorizontalAlignment="Left" Margin="12,108,0,0" Name="Map1" 
            VerticalAlignment="Top" Height="318" Width="483" >
        
    <esri:ArcGISTiledMapServiceLayer ID="PhysicalTiledLayer" 
                   Url="http://services.arcgisonline.com/ArcGIS/rest/services/World_Topo_Map/MapServer" />
          
    <!-- It is important to provide the GraphicsLayer with an 'ID' Attribute so to be able to access it
         in the code-behind file. -->
    <esri:GraphicsLayer ID="MyGraphicsLayer" >
        
      <esri:GraphicsLayer.Graphics>
            
        <!-- Each Graphic added to the GraphicsLayer will have it's symbology and geometry defined. -->
                  
        <esri:Graphic Symbol="{StaticResource RedMarkerSymbol}" >
          <esri:MapPoint X="-7356594.25" Y="4752385.95" SpatialReference="{StaticResource theSpatialReference}"/>
        </esri:Graphic>
        
        <esri:Graphic Symbol="{StaticResource RedMarkerSymbol}" >
          <esri:MapPoint X="3654893.89" Y="7718746.02" SpatialReference="{StaticResource theSpatialReference}"/>
        </esri:Graphic>
        
        <esri:Graphic Symbol="{StaticResource RedMarkerSymbol}" >
          <esri:MapPoint X="6801033.36" Y="10325547.30" SpatialReference="{StaticResource theSpatialReference}"/>
        </esri:Graphic>
        
        <esri:Graphic Symbol="{StaticResource RedMarkerSymbol}" >
          <esri:MapPoint X="-5468910.57" Y="1741081.03" SpatialReference="{StaticResource theSpatialReference}"/>
        </esri:Graphic>
        
        <esri:Graphic Symbol="{StaticResource RedMarkerSymbol}" >
          <esri:MapPoint X="-4614958.43" Y="-326382.05" SpatialReference="{StaticResource theSpatialReference}"/>
        </esri:Graphic>
        
      </esri:GraphicsLayer.Graphics>
          
    </esri:GraphicsLayer>
    
  </esri:Map>
  
  <!-- Provide the instructions on how to use the sample code. -->
  <TextBlock Height="40" HorizontalAlignment="Left" Name="TextBlock1" VerticalAlignment="Top" 
             Width="483" TextWrapping="Wrap" Margin="12,12,0,0" 
             Text="Click the button to select every other Graphic and then change the Symbol of the 
             selected Graphics to one that was defined in XAML." />
    
  <!-- Add a button to perform the work. -->
  <Button Content="Select every other Graphic and change its Symbology" Height="23" HorizontalAlignment="Left" 
          Margin="91,79,0,0" Name="Button1" VerticalAlignment="Top" Width="335" Click="Button1_Click"/>
  
</Grid>
C#Copy Code
private void Button1_Click(object sender, System.Windows.RoutedEventArgs e)
{
  // Obtain the GraphicsLayer that was defined in XAML. 
  ESRI.ArcGIS.Client.GraphicsLayer theGraphicsLayer = null;
  theGraphicsLayer = (ESRI.ArcGIS.Client.GraphicsLayer)(Map1.Layers["MyGraphicsLayer"]);
  
  // Get the GraphicCollection from the GraphicsLayer
  ESRI.ArcGIS.Client.GraphicCollection theGraphicsCollection = theGraphicsLayer.Graphics;
  
  // Call a function to select every other Graphic
  SelectEveryOtherGraphic(theGraphicsCollection);
  
  // Call a function to change the Symbology of the selected Graphics
  RenderSelectedGraphicsDifferently(theGraphicsCollection);
}
            
public void SelectEveryOtherGraphic(ESRI.ArcGIS.Client.GraphicCollection theGraphicsCollection)
{
  // Select every other Graphic in the GraphicsCollection
  for (int i = 0; i < theGraphicsCollection.Count; i += 2)
    theGraphicsCollection(i).Selected = true;
}
            
public void RenderSelectedGraphicsDifferently(ESRI.ArcGIS.Client.GraphicCollection theGraphicsCollection)
{
  // Render the Selected Graphics in the GraphicsCollection with a different Symbol that was defined in XAML.
  
  // Obtain the SimpleMarkerSymbol that was defined in XAML.
  ESRI.ArcGIS.Client.Symbols.SimpleMarkerSymbol theSelectedMarkerSymbol = null;
  theSelectedMarkerSymbol = (ESRI.ArcGIS.Client.Symbols.SimpleMarkerSymbol)(LayoutRoot.Resources["SelectedMarkerSymbol"]);
  
  // Loop through all of the individual Graphic objects in the GraphicsCollection
  foreach (ESRI.ArcGIS.Client.Graphic aGraphic in theGraphicsCollection)
  {
    // If the Graphic was Selected then change its symbology.
    if (aGraphic.Selected == true)
    {
      aGraphic.Symbol = (ESRI.ArcGIS.Client.Symbols.Symbol)theSelectedMarkerSymbol;
    }
  }
}
VB.NETCopy Code
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.Windows.RoutedEventArgs)
  
  ' Obtain the GraphicsLayer that was defined in XAML. 
  Dim theGraphicsLayer As ESRI.ArcGIS.Client.GraphicsLayer
  theGraphicsLayer = CType(Map1.Layers("MyGraphicsLayer"), ESRI.ArcGIS.Client.GraphicsLayer)
  
  ' Get the GraphicCollection from the GraphicsLayer
  Dim theGraphicsCollection As ESRI.ArcGIS.Client.GraphicCollection = theGraphicsLayer.Graphics
  
  ' Call a function to select every other Graphic
  SelectEveryOtherGraphic(theGraphicsCollection)
  
  ' Call a function to change the Symbology of the selected Graphics
  RenderSelectedGraphicsDifferently(theGraphicsCollection)
  
End Sub
  
Public Sub SelectEveryOtherGraphic(ByVal theGraphicsCollection As ESRI.ArcGIS.Client.GraphicCollection)
  
  ' Select every other Graphic in the GraphicsCollection
  For i As Integer = 0 To theGraphicsCollection.Count - 1 Step 2
    theGraphicsCollection(i).Selected = True
  Next i
  
End Sub
            
Public Sub RenderSelectedGraphicsDifferently(ByVal theGraphicsCollection As ESRI.ArcGIS.Client.GraphicCollection)
  
  ' Render the Selected Graphics in the GraphicsCollection with a different Symbol that was defined in XAML.
  
  ' Obtain the SimpleMarkerSymbol that was defined in XAML.
  Dim theSelectedMarkerSymbol As ESRI.ArcGIS.Client.Symbols.SimpleMarkerSymbol
  theSelectedMarkerSymbol = CType(LayoutRoot.Resources("SelectedMarkerSymbol"), ESRI.ArcGIS.Client.Symbols.SimpleMarkerSymbol)
  
  ' Loop through all of the individual Graphic objects in the GraphicsCollection
  Dim aGraphic As ESRI.ArcGIS.Client.Graphic
  For Each aGraphic In theGraphicsCollection
    
    ' If the Graphic was Selected then change its symbology.
    If aGraphic.Selected = True Then
      aGraphic.Symbol = CType(theSelectedMarkerSymbol, ESRI.ArcGIS.Client.Symbols.Symbol)
    End If
    
  Next
  
End Sub

Requirements

Target Platforms:Windows Phone 7

See Also

© ESRI, Inc. All Rights Reserved.