Bug 37526 - XAML bindings not working with dynamic view model properties
Summary: XAML bindings not working with dynamic view model properties
Status: RESOLVED INVALID
Alias: None
Product: Forms
Classification: Xamarin
Component: Forms ()
Version: 2.0.0
Hardware: PC Mac OS
: Normal normal
Target Milestone: ---
Assignee: Bugzilla
URL:
Depends on:
Blocks:
 
Reported: 2016-01-08 16:41 UTC by John Miller [MSFT]
Modified: 2016-01-11 18:05 UTC (History)
4 users (show)

Tags:
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 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 INVALID

Description John Miller [MSFT] 2016-01-08 16:41:39 UTC
**Overview:**

   The attached project creates properties dynamically via some reflection. The XAML bindings to the ViewModel properties are showing errors that they are bound to the wrong types and it's unclear why. 

**Steps to Reproduce:**

   1. Run the attached project on Android simulator. 
   2. In the 3 entry controls on the first screen, enter anything and then Login
   3. Press the button in the middle of the screen to launch the next
   4. Modify the first Entry (1001) to anything and observe the Application Output in XS. 

**Actual Results:**

   Binding: 1001aaa can not be converted to type 'Xamarin.Forms.Command'

**Expected Results:**

   The binding to the property that is 1001 should be a string, not a Command. It's unclear why it's using the Command binding from the Button in the XAML. 

**Build Date & Platform:**

   XF 2.0

**Additional Information:**

   I noticed that it appears to be using whatever was the last control in the XAML. So if you comment out the Button, it will error because of DateTime, which is from the last element in the XAML -> DatePicker. Comment that out, and now its uses String from the Entry. 

The customer is unsure what is wrong in their dynamic code to do this and needs help making sure it's not an issue with how XAML bindings work.
Comment 2 Parmendra Kumar 2016-01-11 18:00:45 UTC
I have tried to reproduce this issue and able to reproduce it. To reproduce this issue I have followed the steps mentioned in bug description.

Screencast: http://www.screencast.com/t/unqTPd6PLOZ2

ApplicationOutput: https://gist.github.com/Parmendrak/685cf77d238c307019b5
BuildOutput: https://gist.github.com/Parmendrak/eb28ca22fb3e58e7d241
IDE Log: https://gist.github.com/Parmendrak/e8f8116ba04cb9029484

Environment Info: 

Xamarin.Forms Version: X.F 2.0.0.6490, 2.0.1.6492-pre1

=== Xamarin Studio ===

Version 5.10.2 (build 49)
Installation UUID: 05cfbdd7-b4af-41cd-945a-9db8b054b749
Runtime:
	Mono 4.2.2 (explicit/11c1351)
	GTK+ 2.24.23 (Raleigh theme)

	Package version: 402010003

=== Xamarin.Profiler ===

Not Installed

=== Xamarin.Android ===

Version: 6.0.1.5 (Enterprise Edition)
Android SDK: /Users/360_macmini/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)
		5.1    (API level 22)
		6.0    (API level 23)

SDK Tools Version: 24.4
SDK Platform Tools Version: 23.0.1
SDK Build Tools Version: 23.0.1

Java SDK: /usr
java version "1.8.0_31"
Java(TM) SE Runtime Environment (build 1.8.0_31-b13)
Java HotSpot(TM) 64-Bit Server VM (build 25.31-b07, mixed mode)

=== Xamarin Android Player ===

Version: 0.4.4
Location: /Applications/Xamarin Android Player.app

=== Apple Developer Tools ===

Xcode 7.2 (9548)
Build 7C68

=== Xamarin.iOS ===

Version: 9.4.1.20 (Enterprise Edition)
Hash: 122b860
Branch: master
Build date: 2016-01-05 20:20:30-0500

=== Xamarin.Mac ===

Version: 2.4.1.5 (Enterprise Edition)

=== Build Information ===

Release ID: 510020049
Git revision: deed4cd240ff3611c8742bbc62296e207f46173d
Build date: 2015-12-17 11:13:36-05
Xamarin addins: 8bd975e7b465f6fe812b64d736f3b7e8c1a79a3e
Build lane: monodevelop-lion-cycle6-c6sr1

=== Operating System ===

Mac OS X 10.10.5
Darwin ShrutiMac.local 14.5.0 Darwin Kernel Version 14.5.0
    Wed Jul 29 02:26:53 PDT 2015
    root:xnu-2782.40.9~1/RELEASE_X86_64 x86_64
Comment 3 John Miller [MSFT] 2016-01-11 18:05:11 UTC
Customer has solved this issue:

The problem was with the code in DictionaryModel -> GetTypeInfo
​
This call needs to be in platform specific project rather than in PCL. I moved it down there and it seems like it’s working fine