Thanks for your project and data, I reproduced your problem and found what’s the reason of that.
The reason is the text style you set to each zoomlevel is object reference, so if you modify anyone, all the other levels will get the same result.
Our suggestion is:
Split shape and labels into different layers
private void UseInMemory(object sender, RoutedEventArgs e)
(map.Overlays as LayerOverlay).Layers.Clear();
InMemoryFeatureLayer shapeLayer = CreateInMemoryLayer(); // Create shape layer
shapeLayer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;
shapeLayer.ZoomLevelSet.ZoomLevel01.DefaultPointStyle = _pointStyle;
InMemoryFeatureLayer labelLayer = CreateInMemoryLayer(); // Create label layer
TextStyle tempStyle = _textStyle.CloneDeep() as TextStyle;
tempStyle.TextColumnName = labelLayer.FeatureSource.GetColumns().ColumnName;
ApplyTextStyles(labelLayer.ZoomLevelSet, tempStyle, 1, 20);
(map.Overlays["MainOverlay"] as LayerOverlay).Layers.Add("layer1", shapeLayer);
(map.Overlays["MainOverlay"] as LayerOverlay).Layers.Add("layerLabel", labelLayer);
Then you can set ZoomLevel.IsActive instead of set style.isActive. (We found a bug here, please upgrade to the latest package today to make ZoomLevel.IsActive works) Please notice, if you set ApplyUntilZoomLevel property, each scale(zoomlevel or custom zoomlevel) between this region will be drawn always, which means IsActive don’t works when the level contained by ApplyUntilZoomLevel.
So you should want use a funtion to assign style:
private void ApplyTextStyles(ZoomLevelSet set, TextStyle style, int applyFromLevel, int applyToLevel)
int index = 1;
foreach (ZoomLevel level in set.GetZoomLevels())
if (index >= applyFromLevel && index <= applyToLevel)
level.DefaultTextStyle = style;
And your code have another problem:
The layer.ZoomLevelSet.GetZoomLevels() return a new collection, which means all your changes in it won’t pass back to map. So please directly set the IsActive to zoomlevel for example: layer.ZoomLevelSet.ZoomLevel05.IsActive = false, or you can create a new ZoomLevelSet with the modified values and set it back.
The other thing you need notice is because your map don’t use the same zoomlevelset with your layer, which means the levels in map and layer is not match, so maybe one level in layer corresponding more levels when you zoom in and zoom out.
If you hadn’t upgrade the package, you can choose set style or set null for specified level, it also should works for your scenario.