Dockpane no longer shows up when button is clicked

825
7
02-25-2021 08:50 AM
JeffSauder
Occasional Contributor

I have a dockpane that was working pretty well, I was testing how it might come up if I docked it, so I set dock= to "group" in the config.daml file.  The dockpane no longer shows up, when I click the button to show the dockpane it turns gray.  I changed it back to "float" (i actually used ctrl-z to undo changing it to "group", in case I typed something wrong.  It still just has the grayed out button, without opening the dockpane, so I guess I broke something?  I tried debugging code but when I break it just shows that it's in "break mode".  The code for the button is below, none of that has changed.  I put a breakpoint on the onclick event and it never hit it, so for some reason it's not being called when I click the button?

internal class dpIDTools_ShowButton : Button
{
protected override void OnClick()
{
dpIDToolsViewModel.Show();
}
}

This is in the config.daml:

<dockPanes>
<dockPane id="CustomIDDockPane_dpIDTools" caption="dpIDTools" className="dpIDToolsViewModel" dock="float" dockWith="esri_core_projectDockPane">
<content className="dpIDToolsView" />
</dockPane>
</dockPanes>

Thanks in advance for any suggestions that may help me resolve this.

 

Jeff

 

Tags (2)
0 Kudos
7 Replies
KirkKuykendall1
Occasional Contributor III

Maybe post the daml for the button too.

Also consider quitting Pro, renaming C:\Users\<yourusername>\AppData\Local\ESRI\ArcGISSettings.xml

to: C:\Users\<yourusername>\AppData\Local\ESRI\ArcGISSettings_backup.xml, restarting Pro.

See if that clears anything up.  If not, restore from the backup.

 

0 Kudos
JeffSauder
Occasional Contributor

Yeah I saw that right after I posted, that I forgot to include the button daml xml.

<button id="CustomIDDockPane_dpIDTools_ShowButton" caption="Show ID Tools Pane" className="dpIDTools_ShowButton" loadOnClick="true" smallImage="pack://application:,,,/ArcGIS.Desktop.Resources;component/Images/GenericButtonPurple16.png" largeImage="pack://application:,,,/ArcGIS.Desktop.Resources;component/Images/GenericButtonPurple32.png">
<tooltip heading="Show Dockpane">Show Dockpane<disabledText /></tooltip>
</button>
</controls>
<dockPanes>
<dockPane id="CustomIDDockPane_dpIDTools" caption="dpIDTools" className="dpIDToolsViewModel" dock="float" dockWith="esri_core_projectDockPane">
<content className="dpIDToolsView" />
</dockPane>
</dockPanes>

Thanks for the suggestions, I'll give it a shot.

While I am getting more used to the Pro programming stuff, at times I'm almost afraid to touch anything, because of stuff like this.  I had to rebuild the xaml pretty much from scratch after removing a button from the xaml code and then got like 15 errors for malformed xml, I replaced the code and didn't fix it (in that case, I hadn't saved the file, so I went to the xaml file on my drive, opened it in notepad, and copied and pasted it into the xaml file, didn't fix it.)

Thanks again for the quick reply, I'll try it and post back shortly.

 

0 Kudos
KirkKuykendall1
Occasional Contributor III

I recommend learning git

0 Kudos
JeffSauder
Occasional Contributor

I added that to my bookmarks, thanks

 

0 Kudos
UmaHarano
Esri Regular Contributor

Hi,

My guess is that the button class name, namespace has changed - causing a mismatch to what is declared in the config.daml of the add-in.  Pro is not able to find the code behind for the button.

Can you please try some of the solutions documented here: Namespace mismatch causes controls to not work or disappear 

Thanks

Uma

0 Kudos
JeffSauder
Occasional Contributor

I've double, even triple checked those names, even cut/paste from one to the other to make sure they were exact, still get the same thing.  I also tried renaming the Pro settings file, so that a new one could be created, didn't help.  Even restoring from yesterday's backup didn't help.  However, from the backup I did have to fix the xaml that got messed up on me again, since that's something that I fixed this morning and was part of yesterday's version.  I did that (both times) by adding a new dockpane, then changing all the IDs to the ID of the broken dockpane, replacing the xaml in the broken one with that xaml code, then pasting in the code for my controls.  Maybe that had something to do with it, although it was working fine after I did that.

I just went ahead and added a new dockpane, set it up in the tool, pasted my controls into the xaml and copied all my code, properties, etc. over from the other one, and it works OK now.

I did notice on the Button class in the viewmodel, that there is a warning about on the line internal class dpIDTools_ShowButton : Button about a naming rule violation since it starts with lowercase.  It's just a warning, and didn't seem to matter before, but I went ahead and made the new one starting with uppercase

0 Kudos
Wolf
by Esri Regular Contributor
Esri Regular Contributor

ArcGIS Pro is using 'just in time loading' of add-ins. So when Pro starts and displays your button's icon on the tool bar, it is only the icon that is displayed, your add-in code is not running yet.  Note that this behavior can be changed in the config.daml under the module tag, but by default 'just in time loading' is enabled.  Once you click on the button though (or your dockpane is shown), your code is loaded and executed.  So if you click a button and it turns unexpectedly gray one reason can be (as already mentioned by Uma) that your code-behind cannot find the code-behind class name as referenced by name in the className attribute like in this example:

<button id="..." caption="..." 
  className="Dockpane1_ShowButton" 
  loadOnClick="true" smallImage="....png" largeImage="....png">
</button

So if you change the class name in the code-behind and not in the config.daml you get the 'gray' button effect.  You can also get a 'gray' button if you code-behind is throwing an exception on startup.  As mentioned by Kirk, I would recommend to use source control in which case you can locate your 'suspect' code changes easily be comparing you latest non-functional code with the last working version.

0 Kudos