<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Get reference of button from Module in ArcGIS Pro SDK Questions</title>
    <link>https://community.esri.com/t5/arcgis-pro-sdk-questions/get-reference-of-button-from-module/m-p/1037466#M6360</link>
    <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;I've added simple button in my Addin and executing some business functionalities by clicking on button.&lt;/P&gt;&lt;P&gt;I'm capturing&amp;nbsp;ProjectOpenedEvent&amp;nbsp; in Module1.cs and want to execute come code located in button class.&amp;nbsp;&lt;/P&gt;&lt;P&gt;No dockpanel associated with button so can't use&amp;nbsp;FrameworkApplication.DockPaneManager.Find.&lt;/P&gt;&lt;P&gt;I want to call public function defined in button from Module1.cs but not sure how to take reference of button data context.&lt;/P&gt;&lt;P&gt;Any help would be appreciated.&lt;/P&gt;&lt;P&gt;-Prashant&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 17 Mar 2021 03:16:19 GMT</pubDate>
    <dc:creator>PrashantKirpan</dc:creator>
    <dc:date>2021-03-17T03:16:19Z</dc:date>
    <item>
      <title>Get reference of button from Module</title>
      <link>https://community.esri.com/t5/arcgis-pro-sdk-questions/get-reference-of-button-from-module/m-p/1037466#M6360</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;I've added simple button in my Addin and executing some business functionalities by clicking on button.&lt;/P&gt;&lt;P&gt;I'm capturing&amp;nbsp;ProjectOpenedEvent&amp;nbsp; in Module1.cs and want to execute come code located in button class.&amp;nbsp;&lt;/P&gt;&lt;P&gt;No dockpanel associated with button so can't use&amp;nbsp;FrameworkApplication.DockPaneManager.Find.&lt;/P&gt;&lt;P&gt;I want to call public function defined in button from Module1.cs but not sure how to take reference of button data context.&lt;/P&gt;&lt;P&gt;Any help would be appreciated.&lt;/P&gt;&lt;P&gt;-Prashant&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 17 Mar 2021 03:16:19 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-sdk-questions/get-reference-of-button-from-module/m-p/1037466#M6360</guid>
      <dc:creator>PrashantKirpan</dc:creator>
      <dc:date>2021-03-17T03:16:19Z</dc:date>
    </item>
    <item>
      <title>Re: Get reference of button from Module</title>
      <link>https://community.esri.com/t5/arcgis-pro-sdk-questions/get-reference-of-button-from-module/m-p/1037626#M6366</link>
      <description>&lt;P&gt;Your Button will have an id in the &amp;lt;button&amp;gt; tag found in the Config.daml.&amp;nbsp; &amp;nbsp;If you want to do the equivalent of clicking the button programmatically.&amp;nbsp; You need the following code.&amp;nbsp; Hope that helps.&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;var iCommand = FrameworkApplication.GetPlugInWrapper("&amp;lt;Your Button's ID Goes Here&amp;gt;") as ICommand;
if (iCommand != null &amp;amp;&amp;amp; iCommand.CanExecute(null))
    iCommand.Execute(null);&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 17 Mar 2021 15:40:59 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-sdk-questions/get-reference-of-button-from-module/m-p/1037626#M6366</guid>
      <dc:creator>DHuantes</dc:creator>
      <dc:date>2021-03-17T15:40:59Z</dc:date>
    </item>
    <item>
      <title>Re: Get reference of button from Module</title>
      <link>https://community.esri.com/t5/arcgis-pro-sdk-questions/get-reference-of-button-from-module/m-p/1037730#M6369</link>
      <description>&lt;P&gt;As best practice the SDK team usually recommends to add common code to the Module class and then call the common code from buttons, tools etc. as shown in this example:&amp;nbsp;&amp;nbsp;&lt;A href="https://github.com/Esri/arcgis-pro-sdk-community-samples/blob/19a330dcbe57cdbbde7f0762e9321aa7b411c827/Map-Exploration/OverlayGroundSurface/MakeManyPolygons.cs#L52-52" target="_self"&gt;https://github.com/Esri/arcgis-pro-sdk-community-samples/blob/19a330dcbe57cdbbde7f0762e9321aa7b411c827/Map-Exploration/OverlayGroundSurface/MakeManyPolygons.cs#L52-52&lt;/A&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The&amp;nbsp;GetPlugInWrapper method shown in the reply above only gives you access to the ICommand interface but doesn't give you access to the underlying classes.&amp;nbsp; You also have to consider the&amp;nbsp;just-in-time (JIT) strategy that is used for all controls in ArcGIS Pro:&amp;nbsp;By default, controls&amp;nbsp;appear enabled, but are not actually instantiated until they are clicked. This&amp;nbsp;just-in-time (JIT) strategy improves resource utilization and startup&amp;nbsp;time by deferring the instantiation of controls until they are initiated by the&amp;nbsp;end user, however, this can be a problem if you try to share common code that is part of an instance of class (for example a Button or MapTool class).&amp;nbsp; We recommend the Module class singleton for these common code patterns.&amp;nbsp; You can add them either as 'static' methods (or properties) or add them to the Module class instance.&amp;nbsp; The Module class instance provides an accessor out-of-box with this property: &lt;EM&gt;public static Module1 Current.&amp;nbsp;&amp;nbsp;&lt;/EM&gt;You can then use Module1.Current to get to the instance.&lt;/P&gt;</description>
      <pubDate>Wed, 17 Mar 2021 18:01:50 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-sdk-questions/get-reference-of-button-from-module/m-p/1037730#M6369</guid>
      <dc:creator>Wolf</dc:creator>
      <dc:date>2021-03-17T18:01:50Z</dc:date>
    </item>
  </channel>
</rss>

