Hi Mike,
The ArcGIS Pro SDK wiki explains how to 'subscribe' to Pro Events using the Pro SDK in general: ProConcepts Framework Events Specifically when you subscribe to an LayerAddedEvent you have to look at the parameter required for the Subscribe method (API Reference) :
public static SubscriptionToken Subscribe(
Action<LayerEventsArgs> action,
bool keepSubscriberAlive
)
The parameter Action<LayerEventsArgs> indicates that you have to specify a 'delegate' (action method) here. The delegate action method has one parameter LayerEventsArgs and looking at the members of LayerEventsArgs you will notice that it contains a Layers property which contains the layers (as an enumeration) that are added. To test this i created an add-in module with a single button. The OnClick method for the button contains this test code:
protected override void OnClick()
{
LayersAddedEvent.Subscribe((evtArgs) =>
{
System.Diagnostics.Debug.WriteLine("LayersAddedEvent");
foreach (var lyr in evtArgs.Layers)
{
System.Diagnostics.Debug.WriteLine($@"Added this layer: {lyr.Name}");
}
});
}
To test this i click my button and then add a new layer to my map view and I get the following output in my Visual Studio output window:
LayersAddedEvent
Added this layer: TestMultiPoints