public static async Task SetToUniqueValueColorizer(string layerName, string styleCategory, string styleName, string fieldName) { // Get the layer we want to symbolize from the map Layer oLayer = MapView.Active.Map.Layers.FirstOrDefault <Layer>(m => m.Name.Equals(layerName, StringComparison.CurrentCultureIgnoreCase)); if (oLayer == null) { return; } RasterLayer rasterLayer = (RasterLayer)oLayer; StyleProjectItem style = Project.Current.GetItems <StyleProjectItem>().FirstOrDefault(s => s.Name == styleCategory); if (style == null) { return; } var colorRampList = await QueuedTask.Run(() => style.SearchColorRamps(styleName)); if (colorRampList == null || colorRampList.Count == 0) { return; } CIMColorRamp cimColorRamp = colorRampList[0].ColorRamp; // Creates a new UV Colorizer Definition using the default constructor. UniqueValueColorizerDefinition UVColorizerDef = new UniqueValueColorizerDefinition(fieldName, cimColorRamp); // Creates a new UV colorizer using the colorizer definition created above. CIMRasterUniqueValueColorizer newColorizer = await rasterLayer.CreateColorizerAsync(UVColorizerDef) as CIMRasterUniqueValueColorizer; // Sets the newly created colorizer on the layer. await QueuedTask.Run(() => { rasterLayer.SetColorizer(MapTools.RecalculateColorizer(newColorizer)); }); }