Bug 17099 - Button icons not shown in compiled application
Summary: Button icons not shown in compiled application
Alias: None
Product: Xamarin Studio
Classification: Desktop
Component: GTK# Designer ()
Version: 4.0.13
Hardware: PC Windows
: Normal normal
Target Milestone: master
Assignee: Bugzilla
: 20808 ()
Depends on:
Reported: 2014-01-07 13:02 UTC by Mike
Modified: 2016-03-09 19:42 UTC (History)
5 users (show)

Is this bug a regression?: ---
Last known good build:

Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.

Please create a new report for Bug 17099 on Developer Community or GitHub if you have new information to add and do not yet see a matching new report.

If the latest results still closely match this report, you can use the original description:

  • Export the original title and description: Developer Community HTML or GitHub Markdown
  • Copy the title and description into the new report. Adjust them to be up-to-date if needed.
  • Add your new information.

In special cases on GitHub you might also want the comments: GitHub Markdown with public comments

Related Links:

Description Mike 2014-01-07 13:02:18 UTC
Description of Problem:

Using Xamarin Studio 4.0.12, 4.0.13 and 4.2.2 with Gtk# 2.12.22 for .NET 4.0 on Windows 7.

Moving from Xamarin 4.0.12 to 4.0.13 or 4.2.2, all the buttons in my UI lost their icons - the icons are shown in the Stetic window in Xamarin but not in the compiled application.

Steps to reproduce the problem:
1. Create a simple window with a button that has Button Type = 'Text and icon', and give it a Gtk-* icon.
2. Compile with Xamarin 4.0.12 and note button in the compiled app have icons.
3. Compile again with 4.0.13 and note that buttons in the compiled app do not have icons.

Actual Results:
When compile with 4.0.12 the button (in the compiled app) has an icon; when compiled with 4.0.13 the icon is not shown.  I assume that the same would happen with any other version post 4.0.13 but have only confirmed this with 4.2.2.

Expected Results:
Buttons should have icons with any version of Xamarin post 4.0.12.

How often does this happen? 
Reliably whenever the compiled app is run.

Additional Information:
Looking at the generated code for the various windows and dialogues, 4.0.12 created an HBox to contain the icon and the label then added the HBox to the button, whereas later versions add an icon and a label directly to the button.

Andrew Krause's 'Foundations of Gtk+ development' Chapter 2 states 'The Gtkbutton widget ... is only capable of holding one child'.  My copy of that book is dated 2007 so I guess that Gtk+ has moved on but perhaps Gtk# has not caught up.  It appears that the Stetic code generation might be out of step with the present version of Gtk#.

Have I missed something here?  Is there a work around or do I need to be patient and continue using 4.0.12 until a new new version of Gtk# is released?
Comment 1 Mike 2014-03-17 06:41:26 UTC
I have tried this with the latest updated version of Xamarin Studio (4.2.3 - 60) and Gtk# (2.12.25) and the problem is still there.  Button icons are present in the UI Designer window in Xamarin Studio but not shown in the compiled application.
Comment 2 Mikayla Hutchinson [MSFT] 2014-03-17 23:53:54 UTC
Whether or not to display icons on buttons or not is a GTK theme setting. Stetic always shows the icons else it would not be possible to edit them.

4.0.13 included a fix so that the code generated by the designer would respect theme settings.

Also - it's correct that a button can only hold one child, but that child can be a container with multiple children.
Comment 3 Mike 2014-04-05 05:04:52 UTC
I have done a little more research re the missing button icons and this remains an issue.

I have included in the app the instruction to read and parse the gtkrc file, which from what I have gleaned from Google and the Gtk website is the file that defines the 'theme'.  I have tried all the different versions of gtkrc that I could find and tried altering everything that might influence the buttons, including different engines.  In particular, 'gtk-button-images = 1' looked promising.  I can affect fonts and the sizes of entries and combo boxes, for example, but the button icons in the running application remain stubbornly absent unless I compile with Xmarin studio 4.0.12.  I would be delighted to be proved wrong because I could then move on to the latest version of Xamarin Studio, but I am now as confident as I can be that Stetic is generating incorrect code to try to add both icons and labels individually to the buttons - it needs to go back to putting these in an hbox container then add that to the button, which is what happens with 4.0.12 but apparently changed with 4.0.13.
Comment 4 Mohit Kheterpal 2014-06-23 07:35:14 UTC
Mike provided the additional information of this issue in Bug 20808. I have added this information below and going to mark Bug 20808 is duplicate of this bug.

Here is the Additional Information Provided by Mike:

This problem (icons missing from buttons) is still present in the latest
version of Xamarin Studio. The only way I can get icons displayed in buttons in
the running application with v5.0.1 is to create an hbox containing both the
icon and the label and add that hbox to the button in my own code, which seems
to miss the point of Stetic.  I have quite a lot of buttons; it would be nice
to be able to let Stetic do this for me.
Comment 5 Mohit Kheterpal 2014-06-23 07:37:35 UTC
*** Bug 20808 has been marked as a duplicate of this bug. ***
Comment 6 healingwaters7 2016-02-10 02:11:24 UTC
Problem (or a variant of it) still seems to be present in 5.10.2.

The only way to get the icon to appear if the text is empty.

Once any text is present, the icon no longer appears at run time...
Comment 7 Archi 2016-03-09 10:11:58 UTC
Its even worse. 

In 5.10.3 on Windows 7 I can display a button in the design window with a custom image (bmp) or png together with empty text. But when I run the app it always crashes.

Problem signature:
  Problem Event Name:	CLR20r3
  Problem Signature 01:	myTest.exe
  Problem Signature 02:	1.0.5912.19119
  Problem Signature 03:	56dfeece
  Problem Signature 04:	gdk-sharp
  Problem Signature 05:
  Problem Signature 06:	55e8a84a
  Problem Signature 07:	467
  Problem Signature 08:	70
  Problem Signature 09:	GLib.GException
  OS Version:	6.1.7601.
  Locale ID:	1031
  Additional Information 1:	0a9e
  Additional Information 2:	0a9e372d3b4ad19135b953a78882e789
  Additional Information 3:	0a9e
  Additional Information 4:	0a9e372d3b4ad19135b953a78882e789
Comment 8 Archi 2016-03-09 19:42:26 UTC
Did some more investigation:
Looks like the code for image reference is wrong:

Failed to open file 'E:\Sysop\Eigene Dokumente\XamarinProjects\Slider\Slider\bin\Debug\.\Application.bmp': No such file or directory

In fact the image is here:
"E:\Sysop\Eigene Dokumente\XamarinProjects\Slider\Slider\Application.bmp"