public IElementContainer Container {get;}
Public ReadOnly Property Container As IElementContainer
public IElementContainer Container {get;}
Public ReadOnly Property Container As IElementContainer
//Report the event args when a layout's selection has changed. //At 2.x - ArcGIS.Desktop.Layouts.Events.LayoutSelectionChangedEvent.Subscribe((args) => { // var elements = args.Elements; // string elemNames = "null"; // if (elements != null && elements.Count() > 0) // { // elemNames = string.Join(",", elements.Select(e => e.Name).ToList()); // } // System.Windows.MessageBox.Show("LayoutSelectionChangedEvent:" + // Environment.NewLine + // " arg Elements: " + elemNames.ToString() + // Environment.NewLine + // " arg Layout: " + args.Layout.Name); //}); ArcGIS.Desktop.Layouts.Events.ElementEvent.Subscribe((args) => { if (args.Hint == ElementEventHint.SelectionChanged) { if (args.Container.GetSelectedElements()?.Count() > 0) { var elemNames = string.Join(",", args.Container.GetSelectedElements().Select(e => e.Name).ToList()); System.Diagnostics.Debug.WriteLine($"ElementEventHint.SelectionChanged: {elemNames}"); } } });
//Report the event args when an element has been updated. //At 2.x - ArcGIS.Desktop.Layouts.Events.ElementsUpdatedEvent.Subscribe((args) => //{ // var elements = args.Elements; // string elemNames = "null"; // if (elements != null && elements.Count() > 0) // { // elemNames = string.Join(",", elements.Select(e => e.Name).ToList()); // } // System.Windows.MessageBox.Show("ElementsUpdatedEvent:" + // Environment.NewLine + // " arg Elements: " + elemNames.ToString() + // Environment.NewLine + // " arg Layout: " + args.Layout.Name); //}); ArcGIS.Desktop.Layouts.Events.ElementEvent.Subscribe((args) => { string elemNames = "null"; //can be null if the name was changed if (args.Elements?.Count() > 0) { elemNames = string.Join(",", args.Elements.Select(e => e.Name).ToList()); } else if (args.Container.GetSelectedElements()?.Count() > 0) { elemNames = string.Join(",", args.Container.GetSelectedElements().Select(e => e.Name).ToList()); } if (args.Hint == ElementEventHint.PropertyChanged) { System.Diagnostics.Debug.WriteLine($"ElementEventHint.PropertyChanged: {elemNames}"); } });
Target Platforms: Windows 11, Windows 10