Bug 29406 - toolbar item with binding context and icon property
Summary: toolbar item with binding context and icon property
Status: RESOLVED ANSWERED
Alias: None
Product: Forms
Classification: Xamarin
Component: Android ()
Version: 1.4.2
Hardware: PC Mac OS
: Normal normal
Target Milestone: ---
Assignee: Rui Marinho
URL:
Depends on:
Blocks:
 
Reported: 2015-04-25 19:23 UTC by Alessandro
Modified: 2015-06-29 12:17 UTC (History)
5 users (show)

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


Attachments
project bug (38.29 KB, application/zip)
2015-06-07 17:18 UTC, Alessandro
Details


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 on Developer Community or GitHub with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:
Status:
RESOLVED ANSWERED

Description Alessandro 2015-04-25 19:23:39 UTC
Hi.
I've a toolbaritem

			ToolbarItem toolbarItemGps = new ToolbarItem ();
			toolbarItemGps.BindingContext = App.Gps;
			toolbarItemGps.SetValue (ToolbarItem.IconProperty, "Icon");

In App.Gps (defined as public static Gps Gps { get; set; } ) I have those properties

	public class Gps
	{
		public string Latitude { get; set; }
		public string Longitude { get; set; }
		public string Icon { get; set; }
		public DateTimeOffset DateTime { get; set; }
		public Gps ()
		{
		}
	}


If I change properties

				var position = await locator.GetPositionAsync(timeout: 10000);

				if (position != null) {
					App.Gps.Icon = "gpsconnected";
					App.Gps.Latitude = position.Latitude.ToString();
					App.Gps.Longitude = position.Longitude.ToString();
					App.Gps.DateTime = position.Timestamp;
				} else 
					throw new Exception();

I would like that ToolBar Icon change with "gpsconnected" icon.
The ToolBar Icon is always the "Icon.png" Xamarin icon

Alessandro
Comment 1 Alessandro 2015-04-25 19:45:33 UTC
Ops, it's an error of mine... sorry... I've changed SetBinding with SetValue...
Comment 2 Alessandro 2015-04-25 19:49:51 UTC
Ok, it was a mistake but with 

            toolbarItemGps.SetBinding (ToolbarItem.IconProperty, "Icon");

no icon appear on ToolBarItem...
Comment 3 Rajneesh Kumar 2015-05-06 12:57:35 UTC
I tried to reproduce this issue with the help provided in bug description, but unfortunately I am not able to reproduce  this. 
Could you please provide us a small sample application that demonstrate  this issue, that would be very helpful to reproduce this issue at our end.  
Also if possible please attach Ide logs via Help=>Open Logs Directory=>Ide.Logs (Choose Latest Time stamp) 

Thanks..!

Environment Info:

=== Xamarin Studio ===

Version 5.9 (build 464)
Installation UUID: 011d70a5-dede-428b-ab04-ef451c2e539d
Runtime:
	Mono 4.0.1 ((detached/5a0b19f)
	GTK+ 2.24.23 (Raleigh theme)

	Package version: 400010024

=== Apple Developer Tools ===

Xcode 6.2 (6776)
Build 6C131e

=== Xamarin.iOS ===

Version: 8.10.1.24 (Business Edition)
Hash: 1b48440
Branch: master
Build date: 2015-05-04 17:01:32-0400

=== Xamarin.Android ===

Version: 5.1.0.129 (Business Edition)
Android SDK: /Users/MM/Desktop/android-sdk-macosx
	Supported Android versions:
		2.3    (API level 10)
		4.0.3  (API level 15)
		4.1    (API level 16)
		4.2    (API level 17)
		4.3    (API level 18)
		4.4    (API level 19)
		4.4.87 (API level 20)
		5.0    (API level 21)
Java SDK: /usr
java version "1.7.0_65"
Java(TM) SE Runtime Environment (build 1.7.0_65-b17)
Java HotSpot(TM) 64-Bit Server VM (build 24.65-b04, mixed mode)

=== Xamarin Android Player ===

Version: Unknown version
Location: /Applications/Xamarin Android Player.app

=== Xamarin.Mac ===

Version: 2.0.1.24 (Business Edition)

=== Build Information ===

Release ID: 509000464
Git revision: 97f3c43266a4abe2dff0a31b1afb976de897d099
Build date: 2015-05-04 10:06:54-04
Xamarin addins: 438f3e4b8352e006958552de07c6f54770c9233c

=== Operating System ===

Mac OS X 10.9.5
Darwin MacMini.local 13.4.0 Darwin Kernel Version 13.4.0
    Sun Aug 17 19:50:11 PDT 2014
    root:xnu-2422.115.4~1/RELEASE_X86_64 x86_64
Comment 4 Alessandro 2015-06-07 17:18:28 UTC
Created attachment 11496 [details]
project bug

ok, I post an example.
It's only for Android, I've not test it in iOS.
In Page1.cs you find row 26/27. This works (if you press "change icon" button, you see the icon in toolbar changed).
If you comment row 26/27 and uncomment 30/31, the "change icon" button does not work.
I don't know if I do a mistake in binding. I think it should be correct because the firs binding works (gpsok). the problem is that when I change the _iconStr value, the icon does not change, but it could be also a "property changed" fody problem.

Let me know
Alessandro
Comment 5 Rajneesh Kumar 2015-06-08 07:07:50 UTC
@ Alessandro Thanks a lot for providing the test sample.

I have checked this issue and able to reproduce with the help of attached test sample provided in comment 4. In this test sample I observed that the "change icon" button does not work. Here is the screencast for the same: http://www.screencast.com/t/USxUxq8PJX5s

Ide logs: https://gist.github.com/Rajneesh360Logica/69dd11810e11ac198024
Build Output: https://gist.github.com/Rajneesh360Logica/59bfa3d5c8c56129b255
Application Output: https://gist.github.com/Rajneesh360Logica/68d3b4fe92e2ffe284bd
XAP Logs: https://gist.github.com/Rajneesh360Logica/57734b39e3431fc45839

Thanks..! 

Environment Info:

Xamarin.Forms 1.4.3.6358-pre2

=== Xamarin Studio ===

Version 5.9.4 (build 3)
Installation UUID: 011d70a5-dede-428b-ab04-ef451c2e539d
Runtime:
	Mono 4.0.2 ((detached/198235d)
	GTK+ 2.24.23 (Raleigh theme)

	Package version: 400020004

=== Apple Developer Tools ===

Xcode 6.2 (6776)
Build 6C131e

=== Xamarin.iOS ===

Version: 8.10.2.16 (Business Edition)
Hash: b2ebbc0
Branch: master
Build date: 2015-06-06 01:13:21-0400

=== Xamarin.Android ===

Version: 5.1.4.8 (Business Edition)
Android SDK: /Users/MM/Desktop/android-sdk-macosx
	Supported Android versions:
		2.3    (API level 10)
		4.0.3  (API level 15)
		4.1    (API level 16)
		4.2    (API level 17)
		4.3    (API level 18)
		4.4    (API level 19)
		4.4.87 (API level 20)
		5.0    (API level 21)
Java SDK: /usr
java version "1.7.0_65"
Java(TM) SE Runtime Environment (build 1.7.0_65-b17)
Java HotSpot(TM) 64-Bit Server VM (build 24.65-b04, mixed mode)

=== Xamarin Android Player ===

Version: Unknown version
Location: /Applications/Xamarin Android Player.app

=== Xamarin.Mac ===

Version: 2.0.2.16 (Business Edition)

=== Build Information ===

Release ID: 509040003
Git revision: 71a8c576686882a0ad224f735d9f04a6c08119c8
Build date: 2015-06-04 02:45:11-04
Xamarin addins: 456e0954631a1a80bc90389e99c6d16cd8f09ad3

=== Operating System ===

Mac OS X 10.9.5
Darwin MacMini.local 13.4.0 Darwin Kernel Version 13.4.0
    Sun Aug 17 19:50:11 PDT 2014
    root:xnu-2422.115.4~1/RELEASE_X86_64 x86_64
Comment 6 Rui Marinho 2015-06-29 12:17:26 UTC
Hi Alessandro, the problem is that String is an immutable reference type and doesn't implement INotifyPropertyChanged, so there's no way the binding system knows the string changed. 
The 1st works because your source of the binding, Icon class, implements INotifyPropertyChanged.