Setting button initial state

88
3
10-11-2018 12:05 PM
Highlighted
New Contributor III

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
Highlighted
Esri 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.

Reply
0 Kudos
Highlighted
New Contributor III

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.

Reply
0 Kudos
Highlighted
New Contributor III

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!

Reply
0 Kudos