ArcGIS Pro 3.0 API Reference Guide
ArcGIS.Desktop.Layouts.Events Namespace / ElementEventArgs Class / Hint Property
Example

In This Topic
    Hint Property (ElementEventArgs)
    In This Topic
    Gets the event hint.
    Syntax
    public ElementEventHint Hint {get;}
    Public ReadOnly Property Hint As ElementEventHint
    Example
    ElementEvent_MapFrameActivated_Deactivated
    //Report the event args when a map frame is activated or deactivated.
    
    //At 2.x - ArcGIS.Desktop.Layouts.Events.ActivateMapFrameEvent.Subscribe((args) =>
    //{
    //  System.Windows.MessageBox.Show("ActiveMapFrameEvent:" +
    //  Environment.NewLine +
    //  "   arg IsActivated: " + args.IsActivated.ToString() +
    //  Environment.NewLine +
    //  "   arg Layout: " + args.Layout.Name +
    //  Environment.NewLine +
    //  "   arg MapFrame: " + args.MapFrame.Name);
    //});
    
    ArcGIS.Desktop.Layouts.Events.ElementEvent.Subscribe((args) =>
    {
      var mapFrameName = args.Elements[0].Name;
      if (args.Hint == ElementEventHint.MapFrameActivated)
      {
        System.Diagnostics.Debug.WriteLine($"ElementEventHint.MapFrameActivated: {mapFrameName}");
      }
      else if (args.Hint == ElementEventHint.MapFrameDeactivated)
      {
        System.Diagnostics.Debug.WriteLine($"ElementEventHint.MapFrameDeactivated: {mapFrameName}");
      }
    });
    ElementEvent_ElementAdded
    //Report the event args when an element is added to the layout.
    
    //At 2.x - ArcGIS.Desktop.Layouts.Events.ElementAddedEvent.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("ElementAddedEvent:" +
    //  Environment.NewLine +
    //  "   arg Elements: " + elemNames.ToString() +
    //  Environment.NewLine +
    //  "   arg Layout: " + args.Layout.Name);
    //});
    
    ArcGIS.Desktop.Layouts.Events.ElementEvent.Subscribe((args) =>
    {
      string elemNames = "null";
      if (args.Elements?.Count() > 0)
      {
        elemNames = string.Join(",", args.Elements.Select(e => e.Name).ToList());
      }
      if (args.Hint == ElementEventHint.ElementAdded)
      {
        System.Diagnostics.Debug.WriteLine($"ElementEventHint.ElementAdded: {elemNames}");
      }
    });
    ElementEvent_ElementRemoved
    //Report the event args when an element is removed from the layout.
    
    //At 2.x - ArcGIS.Desktop.Layouts.Events.ElementRemovedEvent.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("ElementRemovedEvent:" +
    //  Environment.NewLine +
    //  "   arg Elements: " + elemNames.ToString() +
    //  Environment.NewLine +
    //  "   arg Layout: " + args.Layout.Name);
    //});
    
    ArcGIS.Desktop.Layouts.Events.ElementEvent.Subscribe((args) =>
    {
      string elemNames = "null";
      if (args.Elements?.Count() > 0)
      {
        elemNames = string.Join(",", args.Elements.Select(e => e.Name).ToList());
      }
      if (args.Hint == ElementEventHint.ElementRemoved)
      {
        System.Diagnostics.Debug.WriteLine($"ElementEventHint.ElementRemoved: {elemNames}");
      }
    });
    ElementEvent_PlacementChanged
    //Report the event args when an element's placement properties are changed.
    
    //At 2.x - ArcGIS.Desktop.Layouts.Events.ElementsPlacementChangedEvent.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("ElementsPlacementChangedEvent:" +
    //  Environment.NewLine +
    //  "   arg Elements: " + elemNames.ToString() +
    //  Environment.NewLine +
    //  "   arg Layout: " + args.Layout.Name);
    //});
    
    ArcGIS.Desktop.Layouts.Events.ElementEvent.Subscribe((args) =>
    {
      string elemNames = "null";
      if (args.Elements?.Count() > 0)
      {
        elemNames = string.Join(",", args.Elements.Select(e => e.Name).ToList());
      }
      if (args.Hint == ElementEventHint.PlacementChanged)
      {
        System.Diagnostics.Debug.WriteLine($"ElementEventHint.PlacementChanged: {elemNames}");
      }
    });
    ElementEvent_StyleChanged
    //Report the event args when an element's style is changed.
    
    //At 2.x - ArcGIS.Desktop.Layouts.Events.ElementStyleChangedEvent.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("ElementStyleChangedEvent:" +
    //  Environment.NewLine +
    //  "   arg Elements: " + elemNames.ToString() +
    //  Environment.NewLine +
    //  "   arg Layout: " + args.Layout.Name);
    //});
    ArcGIS.Desktop.Layouts.Events.ElementEvent.Subscribe((args) =>
    {
      string elemNames = "null";
      if (args.Elements?.Count() > 0)
      {
        elemNames = string.Join(",", args.Elements.Select(e => e.Name).ToList());
      }
      if (args.Hint == ElementEventHint.StyleChanged)
      {
        System.Diagnostics.Debug.WriteLine($"ElementEventHint.StyleChanged: {elemNames}");
      }
    });
    ElementEvent_SelectionChanged
    //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}");
        }
      }
    
    });
    ElementEvent_PropertyChanged
    //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}");
      }
    });
    Requirements

    Target Platforms: Windows 11, Windows 10, Windows 8.1

    See Also