var featureLayer = MapView.Active.Map.GetLayersAsFlattenedList().OfType<FeatureLayer>().FirstOrDefault(); ArcGIS.Desktop.Framework.Threading.Tasks.QueuedTask.Run(() => { // toggle the label visibility featureLayer.SetLabelVisibility(!featureLayer.IsLabelVisible); });
//Note: call within QueuedTask.Run() if (!featureLayer.IsLabelVisible) //set the label's visiblity featureLayer.SetLabelVisibility(true);
Target Platforms: Windows 11, Windows 10