Apply a particular style to all child elements of a Xamarin.Forms element

Ash

I have a Style with target type Grid. I want all Entry child elements within a grid of this style to automatically acquire a particular style.

I've had a look at these:

Styling nested elements in WPF

Apply Style to all child-elements of specific type

The only solution appears to be setting Resources within the parent Style, so this is what I've done:

<Style x:Key="BuggyGrid" TargetType="Grid">
    <!-- bunch of property setters -->
    <Style.Resources>
        <Style TargetType="Entry">
            <Setter Property="FontFamily" Value="Arial" />
        </Style>
    </Style.Resources>
</Style>

However, I get a build error: "No property, bindable property, or event found for 'Resources'".

Why do I get this error?

I'm using Xamarin.Forms 2.3.2.

Steve Chadbourne

The links you have referenced are specific to WPF XAML and do not apply to Xamarin.Forms XAML.

I'm not sure how you would achieve nested styles in Xamarin.Forms.

The only possibility is XamlCSS which I haven't personally used.

https://www.nuget.org/packages/XamlCSS.xamarinforms/2.0.0-pre1

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

Apply style to all contained elements and the element itself

Apply style to ALL elements

Apply CSS Style to child elements

apply css style only by gien child elements

Apply style to child that are under certain element

Apply css style to child element of parent class

How to apply style to child of element with active state

MakeStyles (Material UI) apply style to child element

Apply style to only one element of a map of elements

How to select all elements that are not in an element with a particular id?

does style class affects child elements of that element?

Apply CSS Style for all elements except button

Apply change to all parent elements that contains a certain child element using jQuery

style all the child element without classes?

how to add a css class for all elements that has particular style

documents get elements by classname apply to all element

Get id's of all child elements with a particular class

Angular 2 - Apply conditional style to a directive's child HTML element

How does Layout draw its child elements in Xamarin.Forms?

CSS apply style to all child except if multiple of x

Xamarin Forms - removing a child element from a StackLayout in C#

Xamarin Forms Access every child element's Property

Maui/Xamarin.Forms: Apply properties on all Frames & Labels

Xamarin Forms: How to set all labels style in one liner code?

How to get all elements before a particular element using pure javascript?

Xamarin forms - Style in android

Apply CSS styles to an element depending on its child elements

How to style multiple child elements based on parent element selector condition

How to apply startOffset in the style-section of an svg for all textPath elements?