<Grid Name="MapGrid" Grid.Row="0"> <Grid.Resources> <esriSymbols:SimpleMarkerSymbol x:Name="MyMarkerSymbol" Color="Green" Style="Diamond" Size="10" /> </Grid.Resources> <esri:Map x:Name="MyMap" Grid.RowSpan="2" > <esri:Map.Layers> <esri:ArcGISDynamicMapServiceLayer ID="SchoolSearch3" Url="http://198.182.104.173/ArcGIS/rest/services/SchoolSearch3/MapServer" VisibleLayers="0,1" /> <esri:FeatureLayer ID="MyFeatureLayer" Url="http://198.182.104.173/ArcGIS/rest/services/BikeCounts_Test/MapServer/0" MouseLeftButtonUp="FeatureLayer_MouseLeftButtonUp" DisableClientCaching="True" Mode="OnDemand" OutFields="*" SelectionColor="Yellow" FeatureSymbol="{StaticResource MyMarkerSymbol}" Where="1=1" /> </esri:Map.Layers> </esri:Map> </Grid>
<esri:SimpleRenderer x:Key="MyRenderer"> <esri:SimpleRenderer.Symbol> <esri:SimpleMarkerSymbol Color="Red" Style="Circle" Size="10"/> </esri:SimpleRenderer.Symbol> </esri:SimpleRenderer>
<esri:FeatureLayer Url="http://sampleserver3.arcgisonline.com/ArcGIS/rest/services/HomelandSecurity/operations/FeatureServer/0" Renderer="{StaticResource MyRenderer}"/>
The FeatureLayer's Renderer trumps FeatureSymbol. Since the service already defines a Renderer, the FeatureSymbol is ignored. The only way you can override the Renderer defined by the service is to create your own renderer.
For example:
Under Resources...<esri:SimpleRenderer x:Key="MyRenderer"> <esri:SimpleRenderer.Symbol> <esri:SimpleMarkerSymbol Color="Red" Style="Circle" Size="10"/> </esri:SimpleRenderer.Symbol> </esri:SimpleRenderer>
FeatureLayer..<esri:FeatureLayer Url="http://sampleserver3.arcgisonline.com/ArcGIS/rest/services/HomelandSecurity/operations/FeatureServer/0" Renderer="{StaticResource MyRenderer}"/>
<Grid Name="MapGrid" Grid.Row="0"> <Grid.Resources> <esri:SimpleRenderer x:Key="MyRenderer"> <esri:SimpleRenderer.Symbol> <esriSymbols:SimpleMarkerSymbol x:Name="MyMarkerSymbol" Color="Green" Style="Diamond" Size="10" /> </esri:SimpleRenderer.Symbol> </esri:SimpleRenderer> </Grid.Resources> <esri:Map x:Name="MyMap" Grid.RowSpan="2" > <esri:Map.Layers> <esri:ArcGISDynamicMapServiceLayer ID="SchoolSearch3" Url="http://198.182.104.173/ArcGIS/rest/services/SchoolSearch3/MapServer" VisibleLayers="0,1" /> <esri:FeatureLayer ID="MyFeatureLayer" Url="http://198.182.104.173/ArcGIS/rest/services/BikeCounts_Test/MapServer/0" MouseLeftButtonUp="FeatureLayer_MouseLeftButtonUp" DisableClientCaching="True" Mode="OnDemand" OutFields="*" SelectionColor="Cyan" Renderer="{StaticResource MyRenderer}" Where="1=1" /> </esri:Map.Layers> </esri:Map> </Grid>
I tried your code and it works fine for me except now the selection color is inoperative. How would you provide for that? Would I need another renderer with a different symbol?
<esriSymbols:MarkerSymbol x:Key="SelectMarkerSymbol" > <esriSymbols:MarkerSymbol.ControlTemplate> <ControlTemplate> <Ellipse x:Name="Element" Width="15" Height="15" StrokeThickness="10" Stroke="Green" > <VisualStateManager.VisualStateGroups> <VisualStateGroup x:Name="SelectionStates"> <VisualState x:Name="Unselected" /> <VisualState x:Name="Selected"> <Storyboard> <ColorAnimation Storyboard.TargetName="Element" Storyboard.TargetProperty="(Ellipse.Stroke).(SolidColorBrush.Color)" To="Cyan" Duration="00:00:0.25"/> </Storyboard> </VisualState> </VisualStateGroup> </VisualStateManager.VisualStateGroups> </Ellipse> </ControlTemplate> </esriSymbols:MarkerSymbol.ControlTemplate> </esriSymbols:MarkerSymbol>