private void UniqueValueRenderer_Click(object sender, System.EventArgs e)
{
UniqueValueRenderer newUniqueValueRenderer = new UniqueValueRenderer()
{
DefaultSymbol = new SimpleFillSymbol()
{
Fill = new SolidColorBrush(Colors.Gray)
},
Field = "SUB_REGION"
};
newUniqueValueRenderer.Infos.Add(new UniqueValueInfo()
{
Value = "Pacific",
Symbol = new SimpleFillSymbol()
{
Fill = new SolidColorBrush(Colors.Purple),
BorderBrush = new SolidColorBrush(Colors.Transparent)
}
});
newUniqueValueRenderer.Infos.Add(new UniqueValueInfo()
{
Value = "W N Cen",
Symbol = new SimpleFillSymbol()
{
Fill = new SolidColorBrush(Colors.Green),
BorderBrush = new SolidColorBrush(Colors.Transparent)
}
});
newUniqueValueRenderer.Infos.Add(new UniqueValueInfo()
{
Value = "W S Cen",
Symbol = new SimpleFillSymbol()
{
Fill = new SolidColorBrush(Colors.Cyan),
BorderBrush = new SolidColorBrush(Colors.Transparent)
}
});
newUniqueValueRenderer.Infos.Add(new UniqueValueInfo()
{
Value = "E N Cen",
Symbol = new SimpleFillSymbol()
{
Fill = new SolidColorBrush(Colors.Yellow),
BorderBrush = new SolidColorBrush(Colors.Transparent)
}
});
newUniqueValueRenderer.Infos.Add(new UniqueValueInfo()
{
Value = "Mtn",
Symbol = new SimpleFillSymbol()
{
Fill = new SolidColorBrush(Colors.Blue),
BorderBrush = new SolidColorBrush(Colors.Transparent)
}
});
newUniqueValueRenderer.Infos.Add(new UniqueValueInfo()
{
Value = "N Eng",
Symbol = new SimpleFillSymbol()
{
Fill = new SolidColorBrush(Colors.Red),
BorderBrush = new SolidColorBrush(Colors.Transparent)
}
});
newUniqueValueRenderer.Infos.Add(new UniqueValueInfo()
{
Value = "E S Cen",
Symbol = new SimpleFillSymbol()
{
Fill = new SolidColorBrush(Colors.Brown),
BorderBrush = new SolidColorBrush(Colors.Transparent)
}
});
newUniqueValueRenderer.Infos.Add(new UniqueValueInfo()
{
Value = "Mid Atl",
Symbol = new SimpleFillSymbol()
{
Fill = new SolidColorBrush(Colors.Magenta),
BorderBrush = new SolidColorBrush(Colors.Transparent)
}
});
newUniqueValueRenderer.Infos.Add(new UniqueValueInfo()
{
Value = "S Atl",
Symbol = new SimpleFillSymbol()
{
Fill = new SolidColorBrush(Colors.Orange),
BorderBrush = new SolidColorBrush(Colors.Transparent)
}
});
LayerDrawingOptions layerDrawOptions = new LayerDrawingOptions();
layerDrawOptions.LayerID = 2;
layerDrawOptions.Renderer = newUniqueValueRenderer;
(MyMap.Layers["USA"] as ArcGISDynamicMapServiceLayer).LayerDrawingOptions =
new LayerDrawingOptionsCollection() { layerDrawOptions };
(MyMap.Layers["USA"] as ArcGISDynamicMapServiceLayer).VisibleLayers = new int[] { 2 };
// Changing VisibleLayers will refresh the layer, otherwise an explicit call to Refresh is needed.
//(MyMap.Layers["USA"] as ArcGISDynamicMapServiceLayer).Refresh();
}