Bug 23758 - Entry.Style throws Unable to cast object of type 'Xamarin.Forms.Entry' to type 'Xamarin.Forms.Label' exception
Summary: Entry.Style throws Unable to cast object of type 'Xamarin.Forms.Entry' to typ...
Status: RESOLVED INVALID
Alias: None
Product: Forms
Classification: Xamarin
Component: Forms ()
Version: 1.3.0
Hardware: PC Windows
: Normal normal
Target Milestone: ---
Assignee: Bugzilla
URL:
Depends on:
Blocks:
 
Reported: 2014-10-11 12:12 UTC by Mitch Milam
Modified: 2016-03-18 08:29 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 Mitch Milam 2014-10-11 12:12:30 UTC
Adding the style property to an Entry will result in the following exception:

[0:] 
2014-10-11 09:49:35.666 FormsTemplateiOS[95683:10233109] Binding: '' property not found on 'System.Collections.Generic.Dictionary`2[System.String,System.Object]', target property: 'Xamarin.Forms.Label.Text'
[0:] Binding: '' property not found on 'System.Collections.Generic.Dictionary`2[System.String,System.Object]', target property: 'Xamarin.Forms.Label.Text'
Unhandled Exception:

System.InvalidCastException: Unable to cast object of type 'Xamarin.Forms.Entry' to type 'Xamarin.Forms.Label'.



Code Sample:

            var nameEntry = new Entry
            {
                Placeholder = "Your name",
                VerticalOptions = LayoutOptions.Start,
                Style = Device.Styles.BodyStyle
            };
Comment 1 Rajneesh Kumar 2014-10-13 02:51:33 UTC
I have checked this issue and unable to reproduce this. To reproduce this issue I have followed the steps mentioned below:

1. Create a Xamarin.Forms application 
2. Add an xaml page named "MyPage"
3. Add following code for Entry Label on "MyPage.xaml.cs"
var nameEntry = new Entry
            {
                Placeholder = "Your name",
                VerticalOptions = LayoutOptions.Start,
                Style = Device.Styles.BodyStyle
            };
4. Call "MyPage" in App.cs and build the application
5. Observe that you will get the build error:
Error CS0117: 'Xamarin.Forms.Entry' does not contain a definition for 'Style'

Could you please provide us steps to reproduce, environment info or small sample application? Please let me know that what I am missing to reproduce this issue? That will be helpful to reproduce this issue at our end.

Screencst: http://www.screencast.com/t/fkFrzs6E

Environment Info: 
=== Xamarin Studio ===

Version 5.5 (build 227)
Installation UUID: a7e29e93-6348-4126-9ebc-b2777c96a552
Runtime:
	Microsoft .NET 4.0.30319.18408
	GTK+ 2.24.22 (MS-Windows theme)
	GTK# 2.12.26

=== Xamarin.Android ===

Version: 4.18.0 (Business Edition)
Android SDK: E:\android-sdk
	Supported Android versions:
		2.1    (API level 7)
		2.2    (API level 8)
		2.3    (API level 10)
		3.1    (API level 12)
		4.0    (API level 14)
		4.0.3  (API level 15)
		4.2    (API level 17)
		4.3    (API level 18)
		4.4    (API level 19)
		4.4.87 (API level 20)
		4.5    (API level 21)
Java SDK: C:\Program Files (x86)\Java\jdk1.6.0_39
java version "1.6.0_39"
Java(TM) SE Runtime Environment (build 1.6.0_39-b04)
Java HotSpot(TM) Client VM (build 20.14-b01, mixed mode)

=== Build Information ===

Release ID: 505000227
Git revision: 7b721eeec7a2fa4c4f4de0ecd2aed4dc25edac95
Build date: 2014-10-02 15:51:22-04
Xamarin addins: 99ed56b428b31eba1efaace4d82188d6f334e6ca

=== Operating System ===

Windows 6.2.9200.0 (64-bit)
Comment 2 Mitch Milam 2014-10-13 08:36:58 UTC
those are the steps that I performed.
Comment 3 Rajneesh Kumar 2014-10-15 06:14:44 UTC
I have checked this issue again and followed the mentioned steps above, with updated Xamarin.Forms version 1.2.3.6257 . But in my code I am not able to use the following line of code on entry element:
                               "Style = Device.Styles.BodyStyle"
By adding this I am not able to build the application, and on building getting the same error:
 Error CS0117: 'Xamarin.Forms.Entry' does not contain a definition for 'Style'

Additional Information: I have checked this issue on MAC and getting same behavior as on windows. Could you please provide your environment info ? 

You can get environment info by: Help=>About=>Show details=>Copy Information 

Please let me know if I am missing something.
Comment 4 Jason Smith [MSFT] 2016-03-18 08:29:30 UTC
TargetType of the style must be set to the type it is being applied to