Select to view content in your preferred language

How to correctly load an icon for a button

7094
11
Jump to solution
09-15-2017 08:47 AM
DrewD
by
Regular Contributor

Hello, 

I'm following the community samples and am trying to change the icon for my add in button. Its not working however, even though I have two buttons (one 16x16, other 32x32 like in the samples). They are present in both Images and Dark Images folders too, incase that mattered. They just dont load.

The line in the DAML file

<button........ smallImage="Images\tree16.png" largeImage="Images\tree32.png">

However I also use the same images for a window icon elsewhere, and it works perfectly. I've even tried the EvilGenius16/32.png from the samples and still no luck. Meanwhile the GenericButton16/32 png's do work. I cannot find any reference to the Generic buttons anywhere in the entire project though, so I don't know if I'm missing a resource loading step or something.

11 Replies
Wolf
by Esri Regular Contributor
Esri Regular Contributor

I think this ProGuide explains the issue:  ProGuide Content and Image Resources · Esri/arcgis-pro-sdk Wiki (github.com)

There is a difference when referencing images from DAML versus referencing images from XAML.  The previous posts were DAML references, your example is XAML.

So, when you tried to apply the DAML solution to your XAML it didn't work, because the references and build actions are different for DAML and XAML.

0 Kudos
CarlMagagnosc1
New Contributor

A couple of things I discovered in working through this issue:

  1. The (simplified) syntax for the pack URI here appears to be
    "pack://application:,,,/<project name>;component/Images/<image file name>.png"
    I'm obviously no URI expert, as it took me some time to find that <project name> needed to be the name used for the project.  So if I named my project CustomButton and the image I want to use is cusbut32.png, my pack URI is
    "pack://application:,,,/CustomButton;component/Images/cusbut32.png"
      I was confused by the use of "Module1" for <project name> in some of the documentation.
  2. The above doesn't work if you have a space in the project name, e.g. if I had named my project
    Custom Button, I'd have a space in the pack URI string, and that leads to unexpected results.  There's probably a way around this, but for now I'm making my project names all_one_word.
  3. Visual Studio (version 17.11.4) doesn't appear to recognize that changes to config.daml require a rebuild.  Again, there's probably some dependency that should be enabled, but I haven't figured it out; it may be in ESRI's ArcGIS Pro Module Addin template.  For now I just use Build>Rebuild instead of Build>Build (or Ctrl-Shift-B).

Thanks to everyone else who has contributed here!

Tags (4)
0 Kudos