I have added a custom button to my config.daml file. I only want this button to be enabled when there is a feature selected on the map. Is there a way to be even more specific and enable only when a feature from a certain layer has been selected?
I found this condition in the help files, but it enables the button when I select a layer in the Contents list:
condition="esri_mapping_onlyFeatureLayersSelectedCondition"
If there is not something already available, how would I create a condition to do this?
<button id="ModifyAttributesButton"
caption="Modify Attributes"
className="TestProject.Buttons.ModifyAttributesButton"
loadOnClick="true"
smallImage="Images\16x16\ModifyAttributes16.png"
largeImage="Images\32x32\ModifyAttributes.png">
<tooltip heading="Tooltip Heading">
Modify project attributes<disabledText />
</tooltip>
</button>
Solved! Go to Solution.
I solved this - maybe there is a better way, but this works:
In the Module code, Initialize method, I subscribe to the selection event:
ArcGIS.Desktop.Mapping.Events.MapSelectionChangedEvent.Subscribe(MapSelectionChanged);
Then I can check the selected features for a selection made to my layer and activate the condition:
private void MapSelectionChanged(MapSelectionChangedEventArgs obj)
{
FrameworkApplication.State.Activate("condition_is_project_selected");
foreach (var item in obj.Selection)
{
if (item.Key.ToString().Contains("Projects"))
{
FrameworkApplication.State.Deactivate("condition_is_project_selected");
break;
}
}
}
I solved this - maybe there is a better way, but this works:
In the Module code, Initialize method, I subscribe to the selection event:
ArcGIS.Desktop.Mapping.Events.MapSelectionChangedEvent.Subscribe(MapSelectionChanged);
Then I can check the selected features for a selection made to my layer and activate the condition:
private void MapSelectionChanged(MapSelectionChangedEventArgs obj)
{
FrameworkApplication.State.Activate("condition_is_project_selected");
foreach (var item in obj.Selection)
{
if (item.Key.ToString().Contains("Projects"))
{
FrameworkApplication.State.Deactivate("condition_is_project_selected");
break;
}
}
}