<?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 Start &amp;quot;session&amp;quot; on click? in ArcGIS Pro SDK Questions</title>
    <link>https://community.esri.com/t5/arcgis-pro-sdk-questions/start-quot-session-quot-on-click/m-p/1648667#M13120</link>
    <description>&lt;P&gt;Hi all,&lt;/P&gt;&lt;P&gt;I'd like to use a button to start a "session" in which stuff happens until I click the button again (like an edit session only different behavior).&amp;nbsp;&lt;/P&gt;&lt;P&gt;As best I can tell, when I click the button, it speeds through the behaviour and immediately exits. That is, it views it as a one-time thing instead of as a switch.&lt;/P&gt;&lt;P&gt;How can I change this to more of a turn-on, turn-off thing?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Edit to give a (not the actual thing) example: a counter between button clicks. Count until I click the button again.&lt;/P&gt;</description>
    <pubDate>Mon, 08 Sep 2025 17:48:54 GMT</pubDate>
    <dc:creator>AlfredBaldenweck</dc:creator>
    <dc:date>2025-09-08T17:48:54Z</dc:date>
    <item>
      <title>Start "session" on click?</title>
      <link>https://community.esri.com/t5/arcgis-pro-sdk-questions/start-quot-session-quot-on-click/m-p/1648667#M13120</link>
      <description>&lt;P&gt;Hi all,&lt;/P&gt;&lt;P&gt;I'd like to use a button to start a "session" in which stuff happens until I click the button again (like an edit session only different behavior).&amp;nbsp;&lt;/P&gt;&lt;P&gt;As best I can tell, when I click the button, it speeds through the behaviour and immediately exits. That is, it views it as a one-time thing instead of as a switch.&lt;/P&gt;&lt;P&gt;How can I change this to more of a turn-on, turn-off thing?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Edit to give a (not the actual thing) example: a counter between button clicks. Count until I click the button again.&lt;/P&gt;</description>
      <pubDate>Mon, 08 Sep 2025 17:48:54 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-sdk-questions/start-quot-session-quot-on-click/m-p/1648667#M13120</guid>
      <dc:creator>AlfredBaldenweck</dc:creator>
      <dc:date>2025-09-08T17:48:54Z</dc:date>
    </item>
    <item>
      <title>Re: Start "session" on click?</title>
      <link>https://community.esri.com/t5/arcgis-pro-sdk-questions/start-quot-session-quot-on-click/m-p/1648890#M13121</link>
      <description>&lt;P&gt;Hi Alfred,&lt;/P&gt;&lt;P&gt;To implement a switch/toggle like this, your code needs to manage the "state" of the switch (on or off).&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;If you already have a state management mechanism, just use that.&lt;/LI&gt;&lt;LI&gt;If you do not, I would recommend reading up on standard support for this in the SDK, see this link for&amp;nbsp; example: &lt;A href="https://developers.arcgis.com/documentation/arcgis-pro-sdk/tutorials/manage-the-pro-ui-with-conditions/" target="_blank" rel="noopener"&gt;https://developers.arcgis.com/documentation/arcgis-pro-sdk/tutorials/manage-the-pro-ui-with-conditions/&lt;/A&gt;&lt;UL&gt;&lt;LI&gt;Or, just now Gemini gave me a pretty good, simplified summary that cut through some of the noise in this article.&amp;nbsp;&lt;/LI&gt;&lt;/UL&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;Regardless of which way you go, essentially:&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;When your add-in initializes, initialize your state to desired default, e.g. `stateMyButtonEnabled = true`&lt;/LI&gt;&lt;LI&gt;When user clicks button flip the switch e.g. `stateMyButtonEnabled = !stateMyButtonEnabled `&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;At any point you can check `stateMyButtonEnabled` to know for example if the button is currently enabled or not.&lt;/P&gt;&lt;P&gt;If you go with Pro "conditions", the syntax for getting/setting state is a bit different, but conceptually similar.&amp;nbsp;&lt;/P&gt;&lt;P&gt;```&lt;/P&gt;&lt;P&gt;// from Gemini with prompt "arcgis pro .net toggle button state"&lt;/P&gt;&lt;P&gt;protected override void OnClick()&lt;BR /&gt;{&lt;BR /&gt;// Check if the state is currently active&lt;BR /&gt;if (ArcGIS.Desktop.Framework.State.Contains("stateMyButtonEnabled "))&lt;BR /&gt;{&lt;BR /&gt;// If active, deactivate it&lt;BR /&gt;ArcGIS.Desktop.Framework.State.Deactivate("stateMyButtonEnabled ");&lt;BR /&gt;}&lt;BR /&gt;else&lt;BR /&gt;{&lt;BR /&gt;// If inactive, activate it&lt;BR /&gt;ArcGIS.Desktop.Framework.State.Activate("stateMyButtonEnabled ");&lt;BR /&gt;}&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;```&lt;/P&gt;&lt;P&gt;Good Luck&lt;/P&gt;</description>
      <pubDate>Tue, 09 Sep 2025 12:44:58 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-sdk-questions/start-quot-session-quot-on-click/m-p/1648890#M13121</guid>
      <dc:creator>coryeicher</dc:creator>
      <dc:date>2025-09-09T12:44:58Z</dc:date>
    </item>
  </channel>
</rss>

