AnsweredAssumed Answered

Apply ColorRamp from stylx file to FeatureLayer

Question asked by EternalDOOM on Dec 15, 2016
Latest reply on Dec 16, 2016 by EternalDOOM

Hello,

 

I`m currently in trouble with searching a StyleProjectItem for a specific ColorRamp / ColorRampStyleItem.

 

First I have to say, I want to ship my style-file (*.stylx) with my addin project. So I created a *.stylx file and saved it under my addin project root folder.

 

I`m also shipping the config.json with my project and for that I added both existing items into my VS project and set "always copy" for both files.

 

That all seems to work fine. I can load the style into the project and I can get it from project by style-name but when I search for ColorRamps in the style by searchString I always get null.

 

string stylePath = Path.Combine(JsonReader.addinAssemblyLocation(), "max_honsell_styles.stylx");

var styleLoaded = Project.Current.AddStyleAsync(stylePath);
StyleProjectItem style = Project.Current.GetItems<StyleProjectItem>().First(x => x.Name == "max_honsell_styles");

 

IList<ColorRampStyleItem> colorRamps = style.SearchColorRampsAsync(MY SEARCH STRING AS PART OF COLOR RAMP NAME) as IList<ColorRampStyleItem>;

I have no idea what could be wrong here. 

I also looked into the Assembly Cache, the stylx file is there! If I copy it and load it into ArcGIS pro manually, I see the colorScheme in it with the right name.

Any idea would be very appreciated.

Outcomes