Bug 43335 - StaticResource not found for key {x:Type Label
Summary: StaticResource not found for key {x:Type Label
Alias: None
Product: Forms
Classification: Xamarin
Component: Forms ()
Version: 2.3.2
Hardware: PC Windows
: --- normal
Target Milestone: ---
Assignee: Bugzilla
Depends on:
Reported: 2016-08-14 18:44 UTC by adrianknight89
Modified: 2016-08-16 22:29 UTC (History)
3 users (show)

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

Repro (203.74 KB, application/zip)
2016-08-14 18:44 UTC, adrianknight89

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:

Description adrianknight89 2016-08-14 18:44:26 UTC
Created attachment 17021 [details]

I'm trying to derive from a global style, but I'm getting runtime parse exception. Were you missing the closing curly brace? Please see App.xaml and MainPage.xaml.

This should work: http://stackoverflow.com/questions/11581475/inherit-style-from-default-style

Also, why can't I set ContentPage background color to Lime? It does not work.

Attached is a repro. Tested this on Android S6.

Here's the exception:

08-14 13:29:15.101 E/mono    (24858): 
08-14 13:29:15.101 E/mono    (24858): Unhandled Exception:
08-14 13:29:15.101 E/mono    (24858): Xamarin.Forms.Xaml.XamlParseException: Position 9:33. StaticResource not found for key {x:Type Label
08-14 13:29:15.101 E/mono-rt (24858): [ERROR] FATAL UNHANDLED EXCEPTION: Xamarin.Forms.Xaml.XamlParseException: Position 9:33. StaticResource not found for key {x:Type Label
Comment 1 E.Z. Hart [MSFT] 2016-08-16 22:29:18 UTC
The StackOverflow questions you've linked to is about WPF, not Xamarin.Forms; the XAML is not interchangeable between the two platforms. For Xamarin.Forms, the equivalent would be:

        <Style TargetType="Label" BasedOn="{StaticResource Xamarin.Forms.Label}">
            <Setter Property="FontSize" Value="24"/>

As for setting the background color for ContentPage, at runtime you're actually displaying subclasses of ContentPage, so your global style needs to set ApplyToDerivedTypes to true:

<Style TargetType="ContentPage" ApplyToDerivedTypes="True">
    <Setter Property="BackgroundColor" Value="Lime" />