<?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 setting button initial state with condition in ArcGIS Pro SDK Questions</title>
    <link>https://community.esri.com/t5/arcgis-pro-sdk-questions/setting-button-initial-state-with-condition/m-p/792534#M1622</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I am trying to create an AddIn with two buttons where the state is controlled with conditions.&amp;nbsp; This is working but the button state is Disabled on program startup.&amp;nbsp; I need a way to have one of the buttons Enabled on startup.&amp;nbsp; I can't seem to find any code to allow me to have the button Enabled on startup.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 05 Sep 2019 12:20:50 GMT</pubDate>
    <dc:creator>SamRideout1</dc:creator>
    <dc:date>2019-09-05T12:20:50Z</dc:date>
    <item>
      <title>setting button initial state with condition</title>
      <link>https://community.esri.com/t5/arcgis-pro-sdk-questions/setting-button-initial-state-with-condition/m-p/792534#M1622</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I am trying to create an AddIn with two buttons where the state is controlled with conditions.&amp;nbsp; This is working but the button state is Disabled on program startup.&amp;nbsp; I need a way to have one of the buttons Enabled on startup.&amp;nbsp; I can't seem to find any code to allow me to have the button Enabled on startup.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 05 Sep 2019 12:20:50 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-sdk-questions/setting-button-initial-state-with-condition/m-p/792534#M1622</guid>
      <dc:creator>SamRideout1</dc:creator>
      <dc:date>2019-09-05T12:20:50Z</dc:date>
    </item>
    <item>
      <title>Re: setting button initial state with condition</title>
      <link>https://community.esri.com/t5/arcgis-pro-sdk-questions/setting-button-initial-state-with-condition/m-p/792535#M1623</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Sam&lt;/P&gt;&lt;P&gt;By default, an add-in's module&amp;nbsp;is set to be&amp;nbsp;&lt;SPAN&gt;loaded just-in-time (JIT). So when Pro application loads, your logic to enable the button is not invoked yet.&amp;nbsp; You can change this by&amp;nbsp;modifying the "autoload" attribute in the config.daml - Set this to false.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;&lt;SPAN class="token tag"&gt;&lt;SPAN class="token tag"&gt;&lt;SPAN class="punctuation token"&gt;&amp;lt;&lt;/SPAN&gt;modules&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;&amp;gt;&lt;/SPAN&gt;&lt;/SPAN&gt;
    &lt;SPAN class="token tag"&gt;&lt;SPAN class="token tag"&gt;&lt;SPAN class="punctuation token"&gt;&amp;lt;&lt;/SPAN&gt;insertModule&lt;/SPAN&gt; &lt;SPAN class="attr-name token"&gt;id&lt;/SPAN&gt;&lt;SPAN class="attr-value token"&gt;&lt;SPAN class="punctuation token"&gt;=&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;"&lt;/SPAN&gt;acme_mainModule&lt;SPAN class="punctuation token"&gt;"&lt;/SPAN&gt;&lt;/SPAN&gt; &lt;SPAN class="attr-name token"&gt;caption&lt;/SPAN&gt;&lt;SPAN class="attr-value token"&gt;&lt;SPAN class="punctuation token"&gt;=&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;"&lt;/SPAN&gt;Acme&lt;SPAN class="punctuation token"&gt;"&lt;/SPAN&gt;&lt;/SPAN&gt; 
                  &lt;SPAN class="attr-name token"&gt;className&lt;/SPAN&gt;&lt;SPAN class="attr-value token"&gt;&lt;SPAN class="punctuation token"&gt;=&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;"&lt;/SPAN&gt;MainModule&lt;SPAN class="punctuation token"&gt;"&lt;/SPAN&gt;&lt;/SPAN&gt; &lt;SPAN class="attr-name token"&gt;autoLoad&lt;/SPAN&gt;&lt;SPAN class="attr-value token"&gt;&lt;SPAN class="punctuation token"&gt;=&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;"&lt;/SPAN&gt;false&lt;SPAN class="punctuation token"&gt;"&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;&amp;gt;&lt;/SPAN&gt;&lt;/SPAN&gt;
      &lt;SPAN class="comment token"&gt;&amp;lt;!--Declare additional customizations here..--&amp;gt;&lt;/SPAN&gt;
    &lt;SPAN class="token tag"&gt;&lt;SPAN class="token tag"&gt;&lt;SPAN class="punctuation token"&gt;&amp;lt;/&lt;/SPAN&gt;insertModule&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;&amp;gt;&lt;/SPAN&gt;&lt;/SPAN&gt;
  &lt;SPAN class="token tag"&gt;&lt;SPAN class="token tag"&gt;&lt;SPAN class="punctuation token"&gt;&amp;lt;/&lt;/SPAN&gt;modules&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;&amp;gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;P&gt;Uma&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 09:06:28 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-sdk-questions/setting-button-initial-state-with-condition/m-p/792535#M1623</guid>
      <dc:creator>UmaHarano</dc:creator>
      <dc:date>2021-12-12T09:06:28Z</dc:date>
    </item>
    <item>
      <title>Re: setting button initial state with condition</title>
      <link>https://community.esri.com/t5/arcgis-pro-sdk-questions/setting-button-initial-state-with-condition/m-p/792536#M1624</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks Uma for the response.&amp;nbsp; I have tried that and also set my button's loadOnClick="false" as well.&amp;nbsp; I think that the problem is that I am using a custom condition.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;lt;insertCondition id="Controls_Button_condition" caption="Button Controls"&amp;gt;&lt;BR /&gt; &amp;lt;!-- our condition is set true or false based on this underlying state --&amp;gt;&lt;BR /&gt; &amp;lt;state id="button_state"/&amp;gt;&lt;BR /&gt; &amp;lt;/insertCondition&amp;gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I believe that the condition is evaluated to be false or disabled button at startup.&amp;nbsp; I have no way of setting "button_state" on startup.&amp;nbsp; I have successfully changed the state after running the program and the button will switch between enabled and disabled as I want it to.&amp;nbsp; I just need the button to be enabled on startup and currently, the button starts out disabled.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks in advance for your help.&lt;/P&gt;&lt;P&gt;Sam&amp;nbsp;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 05 Sep 2019 18:05:13 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-sdk-questions/setting-button-initial-state-with-condition/m-p/792536#M1624</guid>
      <dc:creator>SamRideout1</dc:creator>
      <dc:date>2019-09-05T18:05:13Z</dc:date>
    </item>
    <item>
      <title>Re: setting button initial state with condition</title>
      <link>https://community.esri.com/t5/arcgis-pro-sdk-questions/setting-button-initial-state-with-condition/m-p/792537#M1625</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Sam,&lt;/P&gt;&lt;P&gt;One way you can do this -&lt;/P&gt;&lt;P&gt;In your Module class' Initialize override, you can subscribe to an event such as the &lt;A href="https://pro.arcgis.com/en/pro-app/sdk/api-reference/#topic9319.html"&gt;ProjectOpenedEvent&lt;/A&gt;. The event handler can set your custom state.&amp;nbsp; This way when a project opens, your states will get evaluated immediately.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 05 Sep 2019 18:15:46 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-sdk-questions/setting-button-initial-state-with-condition/m-p/792537#M1625</guid>
      <dc:creator>UmaHarano</dc:creator>
      <dc:date>2019-09-05T18:15:46Z</dc:date>
    </item>
    <item>
      <title>Re: setting button initial state with condition</title>
      <link>https://community.esri.com/t5/arcgis-pro-sdk-questions/setting-button-initial-state-with-condition/m-p/792538#M1626</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;This sounds hopeful....&amp;nbsp; I'm not sure how to accomplish what you are suggesting.&amp;nbsp; There is an override in my module now:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;protected override bool CanUnload()&lt;BR /&gt; {&lt;BR /&gt; //TODO - add your business logic&lt;BR /&gt; //return false to ~cancel~ Application close&lt;BR /&gt; return true;&lt;BR /&gt; }&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Can I use this one or do I need to define another override?&amp;nbsp; Also, I am not sure how to subscribe to the ProjectOpenedEvent or how to use the event handler.&amp;nbsp; I guess I am in a little over my head on this one.&amp;nbsp;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 05 Sep 2019 18:28:46 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-sdk-questions/setting-button-initial-state-with-condition/m-p/792538#M1626</guid>
      <dc:creator>SamRideout1</dc:creator>
      <dc:date>2019-09-05T18:28:46Z</dc:date>
    </item>
    <item>
      <title>Re: setting button initial state with condition</title>
      <link>https://community.esri.com/t5/arcgis-pro-sdk-questions/setting-button-initial-state-with-condition/m-p/792539#M1627</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Success!!&amp;nbsp; &amp;nbsp;I found the following code and was able to get it to work.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;SPAN class="" style="color: #d73a49;"&gt;protected&lt;/SPAN&gt; &lt;SPAN class="" style="color: #d73a49;"&gt;override&lt;/SPAN&gt; &lt;SPAN class="" style="color: #d73a49;"&gt;bool&lt;/SPAN&gt; &lt;SPAN class="" style="color: #6f42c1;"&gt;Initialize&lt;/SPAN&gt;() &lt;SPAN class="" style="color: #6a737d;"&gt;//Called when the Module is initialized.&lt;/SPAN&gt;      
{           
&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;SPAN class="" style="color: #24292e;"&gt;ProjectOpenedEvent&lt;/SPAN&gt;.&lt;SPAN class="" style="color: #6f42c1;"&gt;Subscribe&lt;/SPAN&gt;(&lt;SPAN class="" style="color: #24292e;"&gt;OnProjectOpened&lt;/SPAN&gt;); &lt;SPAN class="" style="color: #6a737d;"&gt;//subscribe to Project opened event&lt;/SPAN&gt;          
&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;SPAN class="" style="color: #d73a49;"&gt;return&lt;/SPAN&gt; &lt;SPAN class="" style="color: #d73a49;"&gt;base&lt;/SPAN&gt;.&lt;SPAN class="" style="color: #6f42c1;"&gt;Initialize&lt;/SPAN&gt;();       
}        

&lt;SPAN class="" style="color: #d73a49;"&gt;private&lt;/SPAN&gt; &lt;SPAN class="" style="color: #d73a49;"&gt;void&lt;/SPAN&gt; &lt;SPAN class="" style="color: #6f42c1;"&gt;OnProjectOpened&lt;/SPAN&gt;(&lt;SPAN class="" style="color: #6f42c1;"&gt;ProjectEventArgs&lt;/SPAN&gt; &lt;SPAN class="" style="color: #24292e;"&gt;obj&lt;/SPAN&gt;) &lt;SPAN class="" style="color: #6a737d;"&gt;//Project Opened event handler&lt;/SPAN&gt;      
{           
&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;SPAN class="" style="color: #24292e;"&gt;MessageBox&lt;/SPAN&gt;.&lt;SPAN class="" style="color: #6f42c1;"&gt;Show&lt;/SPAN&gt;(&lt;SPAN class="" style="color: #032f62;"&gt;$"{&lt;SPAN class="" style="color: #24292e;"&gt;Project&lt;/SPAN&gt;.&lt;SPAN class="" style="color: #24292e;"&gt;Current&lt;/SPAN&gt;} has opened"&lt;/SPAN&gt;); &lt;SPAN class="" style="color: #6a737d;"&gt;//show your message box&lt;/SPAN&gt;  
&amp;nbsp;&amp;nbsp;&amp;nbsp;//Put the button code here to activate or deactivate    
}        

&lt;SPAN class="" style="color: #d73a49;"&gt;protected&lt;/SPAN&gt; &lt;SPAN class="" style="color: #d73a49;"&gt;override&lt;/SPAN&gt; &lt;SPAN class="" style="color: #d73a49;"&gt;void&lt;/SPAN&gt; &lt;SPAN class="" style="color: #6f42c1;"&gt;Uninitialize&lt;/SPAN&gt;() &lt;SPAN class="" style="color: #6a737d;"&gt;//unsubscribe to the project opened event&lt;/SPAN&gt;      
{           
&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;SPAN class="" style="color: #24292e;"&gt;ProjectOpenedEvent&lt;/SPAN&gt;.&lt;SPAN class="" style="color: #6f42c1;"&gt;Unsubscribe&lt;/SPAN&gt;(&lt;SPAN class="" style="color: #24292e;"&gt;OnProjectOpened&lt;/SPAN&gt;); &lt;SPAN class="" style="color: #6a737d;"&gt;//unsubscribe&lt;/SPAN&gt;          
&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;SPAN class="" style="color: #d73a49;"&gt;return&lt;/SPAN&gt;;       
}


Thank you so much for your help..... AWESOME!!!!!!!!!!&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 09:06:30 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-sdk-questions/setting-button-initial-state-with-condition/m-p/792539#M1627</guid>
      <dc:creator>SamRideout1</dc:creator>
      <dc:date>2021-12-12T09:06:30Z</dc:date>
    </item>
  </channel>
</rss>

