Select to view content in your preferred language

Show layer custom properties in Esri Layer dialog

427
1
03-13-2023 02:07 PM
StevenCorpus
Emerging Contributor

I created a Plugin Datasource layer that uses a proprietary file as a datasource. CustomProperties are added to this layer upon creation. Is there a way to show these values in the standard Esri layer property dialog where the custom properties are listed on the left along with General, Metadata, Source, etc?

0 Kudos
1 Reply
CharlesMacleod
Esri Regular Contributor

here's an example of a custom page for feature layers: - assuming u have added a property sheet/page to your addin (eg using the item template). The key is updating the desired property sheet collection. In this case, I am updating "esri_mapping_featureLayerPropertySheet" which is the collection for feature layers.

layer_props1.jpg

 

layer_props2.jpg

 

Config.daml (note: by default the template uses "<page..." - note that for "<udpdateSheet" u need to use "<insertPage ..."

<propertySheets>
    <updateSheet refID="esri_mapping_featureLayerPropertySheet">
      <insertPage id="LayerPropertyPageExample_Pages_FeatureLayerCustomPage" 
						caption="Custom Page" className="LayerPropertyPageExample.Pages.FeatureLayerCustomPageViewModel" 
						group="Custom Group">
        <content className="LayerPropertyPageExample.Pages.FeatureLayerCustomPageView" />
      </insertPage>
    </updateSheet>
  </propertySheets>

 

Module1.cs

internal class Module1 : Module {
  ...
 protected override bool Initialize() {
   if (MapView.Active != null) {
     var layers = MapView.Active?.GetSelectedLayers().OfType<FeatureLayer>();
     if (layers?.Count() > 0) {
     var json_settings = new JsonSerializationSettings() {
        PrettyPrint = true
      };
      QueuedTask.Run(() => LayerJSON = layers.First()
          .GetDefinition().ToJson(json_settings));
    }
   }
   ArcGIS.Desktop.Mapping.Events.TOCSelectionChangedEvent
      .Subscribe(async (args) => {
   var layers = args.MapView?.GetSelectedLayers().OfType<FeatureLayer>();
   if (layers?.Count() > 0) {
     var json_settings = new JsonSerializationSettings() {
       PrettyPrint = true
     };
     LayerJSON = await QueuedTask.Run(() => 
        layers.First().GetDefinition().ToJson(json_settings));
    }
   });
   return true;
 }

 private string _layerJSON = "";
 public string LayerJSON {
   get {
      return _layerJSON;
   }
   set {
      _layerJSON = value;
   }
 }

 

Property page View Model and View:

internal class FeatureLayerCustomPageViewModel : Page {
 ...
 public string LayerJSON => Module1.Current.LayerJSON;
}

 

<UserControl x:Class="LayerPropertyPageExample.Pages.FeatureLayerCustomPageView">
  ...
 <Grid>
  <Border BorderThickness="1" Padding="1">
    <Border.BorderBrush>
      <SolidColorBrush Color="{DynamicResource Esri_Color_Blue}"></SolidColorBrush>
    </Border.BorderBrush>
    <ScrollViewer HorizontalScrollBarVisibility="Auto"
		  VerticalScrollBarVisibility="Auto">
     <TextBlock Text="{Binding LayerJSON}"  
                TextWrapping="Wrap"/>
   </ScrollViewer>
  </Border>
 </Grid>
</UserControl>

.