Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
Description of Change
Support cascading StyleSheets.
This code and feature is brand new. The API shouldn't change much, but some of the behaviors might be slightly altered in the future, depending on the feedback received.
Unsupported Selectors (for this version)
Selectors can be combined without limitation, like in
Styles with matching selectors are all applied, one by one, in definition order. Styles defined on the item itself is always applied last.
This is the expected behavior in most cases, even if doesn't 100% match common CSS implementations.
Specificity, and specificity overrides (
Unsupported Common Properties
One, two, three or four values, separated by white spaces.
One of the following value, case insensitive. Exact meaning depends of the platform and the control
alternatively, you can inline your style in a
do not abuse of that second syntax.
From an embedded resource:
or from a
StyleSheet, XamlC and other potential optimizations
At this time, CSS StyleSheets are parsed and evaluated at runtime. That aren't compiled. Every time a StyleSheet is used, it's reparsed again. If parsing time is an issue, enabling caching is trivial, but comes at memory cost.
None. but It'll introduce some new ones
Not that much new API...
nice catch, I'll add them
yes, you can. see https://github.com/xamarin/Xamarin.Forms/pull/1207/files#diff-73f8da31e9d7780757345a55024ff7eaR99 for a test. The "Selector Combination" part of the PR description should state that, but it's still empty
This looks really good.
The only things that are unclear to me are:
- Are there explicit tests for css precedence when two styles match the same element with the same level of specificity? In this case, the latest style should take precedence. And where are you determining "latest style" if the styles are imported from multiple sources (inline should trump resources, etc.)?
- Do we support
- Do we support putting css on an element itself?
style="color: red"? Do we have tests for precedence here?
We need to highlight the breaking changes and deprecations in the PR.
OutlineColor stands out to me.
And the docs dll version will probably need to change before long. :)
Also, I'm sad that we don't support LESS.
we do not support
we don't, on purpose
Even in the HTML world, this is considered very bad practice (quoting MDN here). But you can set the StyleSheet to inline data to any element.
added a commit
this pull request
Dec 15, 2017
Dec 20, 2017
3 of 11 checks passed
added a commit
this pull request
Dec 21, 2017
I am not sure if someone already asked about this before but if someone did, please guide me to the answer.
How to add different CSS for tablets like the iPad or android tablets in general?
so, I had to do many steps to solve this issue such as:
`if (Device.Idiom == TargetIdiom.Phone)
As you can see it's a lot of variables and conditions to set for every page.
Is this issue still there or does CSS provide a solution to that?
NeverMind that long post
referenced this pull request
May 2, 2018
Can styles on an element be changed at runtime? They are applied as expected on initial load but I seem unable to dynamically change them at runtime based on some event. For example, in a page code-behind this scenario:
This has no effect, and does not update