Select to view content in your preferred language

Setting button initial state

477
3
10-11-2018 12:05 PM
MichaelPanlasigui
Occasional Contributor

In my add-in I'm using Delegate Commands to control button sensitivity, but it does not seem to affect the initial button state.  I am not specifying any condition in the DAML, but all buttons appear enabled at startup instead of just the one desired.  Here are the corresponding methods and properties.

internal static void OnConnectButtonClick()
{
   _connected = true;
}

internal static bool CanOnConnectButtonClick
{
   get {
      return !_connected;
   }
}

internal static void OnDisconnectButtonClick()
{
   _connected = false;
}

internal static bool CanOnDisconnectButtonClick
{
   get {
      return _connected;
   }   
}

What am I missing here?  It seems the only way I'm able to achieve the desired effect is to create a configuration with custom conditions and set the condition/state in the OnApplicationReady() method.  Is there a way to accomplish this with just an add-in?

3 Replies
CharlesMacleod
Esri Regular Contributor

unless you use a Condition, you must set Autoload=true in your Config.daml. Otherwise, your add-in is not loaded until your button is clicked.

0 Kudos
MichaelPanlasigui
Occasional Contributor

Thank you, Charles, for the quick reply.  I failed to mention it in the initial post, but I am setting autoLoad="true" in Config.daml.  This does not seem affect the behavior.

0 Kudos
MichaelPanlasigui
Occasional Contributor

Taking your instruction further, in addition to setting autoLoad="true" for the module, I also set loadOnClck="false" on each button.  That seems to do the trick.  Thanks!

0 Kudos