I cannot seem to get the legend to display symbols for my graphics layers. Should the legend be able to do this if a Renderer is used?I took the exact sample from here:http://help.arcgis.com/en/webapi/silverlight/samples/start.htm#LegendSimpleand modified the code behind to add the layer, and referenced a custom symbol. The graphic does show up in the map, and the symbol is properly rendered, but the legend does not display. Is this the expected behavior?Thanks for any ideas or insight you may have
public MainPage()
{
InitializeComponent();
GraphicsLayer gl = new GraphicsLayer();
Graphic gr = new Graphic();
gr.Geometry = new ESRI.ArcGIS.Client.Geometry.MapPoint(-110,34);
gr.Attributes.Add("Sequence", 1);
gl.Graphics.Add(gr);
gl.ID = "my test layer";
SimpleRenderer sr = new SimpleRenderer();
sr.Symbol = new RoutingStopSymbols(new SolidColorBrush(Colors.Red));
MyMap.Layers.Add(gl);
}
public class RoutingStopSymbols : ESRI.ArcGIS.Client.Symbols.MarkerSymbol, ESRI.ArcGIS.Client.IRenderer
{
public static readonly DependencyProperty ColorProperty = DependencyProperty.Register("Color", typeof(Brush), typeof(RoutingStopSymbols), null);
public RoutingStopSymbols(Brush brush)
{
this.Color = brush;
ResourceDictionary resDict = new ResourceDictionary();
resDict.Source = new Uri("/SilverlightApplication7;component/Routing.xaml", UriKind.Relative);
ControlTemplate = resDict["RoutePoint"] as ControlTemplate;
}
public Brush Color
{
get
{
return (Brush)GetValue(ColorProperty);
}
set
{
SetValue(ColorProperty, value);
}
}
public ESRI.ArcGIS.Client.Symbols.Symbol GetSymbol(ESRI.ArcGIS.Client.Graphic graphic)
{
return this;
}
}
<ResourceDictionary
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
>
<ControlTemplate x:Key="RoutePoint" >
<Grid RenderTransformOrigin="0.5,0.5" Width="25" Height="25" >
<Grid.RenderTransform>
<TransformGroup>
<ScaleTransform ScaleX="1" ScaleY="1" />
</TransformGroup>
</Grid.RenderTransform>
<Ellipse x:Name="backgroundCircle" Stroke="black"
Width="25" Height="25"
Fill="{Binding Symbol.Color}"
HorizontalAlignment="Center" VerticalAlignment="Center" />
<TextBlock Text="{Binding Attributes[Sequence]}"
Foreground="White"
HorizontalAlignment="Center" VerticalAlignment="Center"
FontStretch="Expanded" FontSize="12" FontWeight="ExtraBlack" />
</Grid>
</ControlTemplate>
</ResourceDictionary>