Bug 37642 - App-level implicit style is not applied to custom XAML control
Summary: App-level implicit style is not applied to custom XAML control
Alias: None
Product: Forms
Classification: Xamarin
Component: Forms ()
Version: 2.0.0
Hardware: PC Windows
: --- normal
Target Milestone: ---
Assignee: Bugzilla
Depends on:
Reported: 2016-01-13 05:40 UTC by bobme981
Modified: 2016-02-12 12:47 UTC (History)
4 users (show)

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:

Description bobme981 2016-01-13 05:40:26 UTC
I have the following in my Xamarin.Forms 2.0 project:

App.xaml: (partial)

    <Style TargetType="Grid">
      <Setter Property="ColumnSpacing" Value="0" />

MyCustomControl.xaml: (note the root element type)


MyCustomControl.xaml.cs: (note the base class)

public class MyCustomControl : Grid
    public MyCustomControl()

The implicit style setting Grid.ColumnSpacing=0 by default is NOT applied to instances of MyCustomControl.

However, if I revert the base class to a ContentView and nest the Grid inside of that instead, the implicit style IS applied:


The documentation states implicit styles become "the default for all objects of that type." It does not mention any exceptions to this behavior.

See: http://developer.xamarin.com/guides/xamarin-forms/working-with/styles/
Comment 1 Stephane Delcroix 2016-02-12 12:47:53 UTC
implicit properties are not applied to inherited controls in Xamarin.Forms. This is by design, for some good reason I can't remember right now.

Documentation says "for all object of that type". you custom control is of type MyCustomControl, which eventually inherit from Grid, but is not of type Grid.

I'll ask our doc team to clarify this. Thanks For the report.