ArcGIS Pro 3.0 API Reference Guide
ArcGIS.Desktop.Framework.Contracts Namespace / PlugIn Class / OnUpdate Method
Example

In This Topic
    OnUpdate Method (PlugIn)
    In This Topic
    Called periodically by the framework once the tool has been created.
    Syntax
    protected internal virtual void OnUpdate()
    Protected Friend Overridable Sub OnUpdate() 
    Remarks

    The OnUpdate method is called periodically by the framework once the control has been created. This provides an opportunity to run some code within your customization. One typical use of OnUpdate is to determine and set the Enabled property of the control. Note, since OnUpdate is called very frequently, you should avoid lengthy operations in this method as this would reduce the responsiveness of the application user interface.

    Control PlugIns are primarily enabled and disabled based on their associated condition. The control object itself will not be loaded or created until its specified condition is initially met, and thereafter, OnUpdate will not be called unless the supplied context is currently satisfied. Note that the loadOnClick attribute is checked after the condition, so delay loaded controls will still appear disabled if their condition hasn’t yet been satisfied.

    Example
    customize the disabedText property of a button or tool
    //Set the tool's loadOnClick attribute to "false" in the config.daml. 
    //This will allow the tool to be created when Pro launches, so that the disabledText property can display customized text at startup.
    //Remove the "condition" attribute from the tool. Use the OnUpdate method(below) to set the enable\disable state of the tool.
    //Add the OnUpdate method to the tool.
    //Note: since OnUpdate is called very frequently, you should avoid lengthy operations in this method 
    //as this would reduce the responsiveness of the application user interface.
    internal class SnippetButton : ArcGIS.Desktop.Framework.Contracts.Button
    {
      protected override void OnUpdate()
      {
        bool enableSate = true; //TODO: Code your enabled state  
        bool criteria = true;  //TODO: Evaluate criteria for disabledText  
    
        if (enableSate)
        {
          this.Enabled = true;  //tool is enabled  
        }
        else
        {
          this.Enabled = false;  //tool is disabled  
                                 //customize your disabledText here  
          if (criteria)
            this.DisabledTooltip = "Missing criteria 1";
        }
      }
    }
    Requirements

    Target Platforms: Windows 11, Windows 10, Windows 8.1

    See Also