Quantcast
Channel: Xamarin.Forms — Xamarin Community Forums
Viewing all articles
Browse latest Browse all 91519

New Bug?

$
0
0

I set a style in my application start file and tried to set it to an Style in my form page and it returns a null; however, it returns a value if viewed via the intermediate window. Sometimes my Xamarin Studio will hard crash. I am building an Android app with PCL.

Here is the code:

// Code in my App.cs file
var EntryNumeric = new Style (typeof(Entry)) {
                BaseResourceKey = Device.Styles.SubtitleStyleKey,
                Setters = {
                    new Setter { Property = Entry.TextColorProperty, Value = Color.Black },
                    new Setter { Property = Entry.ClassIdProperty, Value = "EditField" },
                    new Setter { Property = Entry.KeyboardProperty, Value = Keyboard.Numeric },
                    new Setter { Property = Entry.IsEnabledProperty, Value = false },
                    new Setter {
                        Property = Entry.BackgroundColorProperty,
                        Value = (Color)Application.Current.Resources ["FieldBackgroundColorDefault"]
                    }
                }
            };
            Application.Current.Resources.Add ("EntryNumeric", EntryNumeric); 

// Code in my form page which results in a null being returned
Style style = (Style)Application.Current.Resources ["EntryNumeric"];

Here is the intermediate window:
?Application.Current.Resources ["EntryNumeric"]
{Xamarin.Forms.Style}
BaseResourceKey: "SubtitleStyle"
BasedOn: (null)
Behaviors: Count = 0
Setters: Count = 5
TargetType: {Xamarin.Forms.Entry}
Triggers: Count = 0
Non-public members:
?style
(null)
Unable to cast object of type 'System.RuntimeType' to type 'Mono.Debugger.Soft.TypeMirror'.


Viewing all articles
Browse latest Browse all 91519

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>