CSS stylesheet in native platform

I used StyleSheet with xamarin.forms and the application works fine.
I put the styles.css file in the shared project.
Now I want to move it in the project of each platform.
How to do that?


  • LandLuLandLu Member, Xamarin Team Xamurai

    Why do you want to place your styles files on each platform? If you want to implement platform related css styles, you can create two styles.css then use OnPlatform syntax to set different styles for different platforms:

                <OnPlatform x:TypeArguments="x:Uri">
                    <On Platform="Android">/Assets/Android.css</On>
                    <On Platform="iOS">/Assets/iOS.css</On>

    These two css files can both be placed in Forms project.

  • MohamedBenSaidMohamedBenSaid USMember ✭✭

    I have multiple Android projects in my solution. Every project is for a client. The only difference is in the resources (drawables, strings.xml, color.xml, ...) and styles.css.

  • LeonidProtsenkoLeonidProtsenko USMember ✭✭
    edited February 17

    I have error: Position 5:14. StyleSheet require either a Source or a content

  • LeonidProtsenkoLeonidProtsenko USMember ✭✭
    edited February 17

    How can I set StyleSheet by platform?

    <StyleSheet Source="{OnPlatform iOS=Styles/AppStylesIos.css, Android=Styles/AppStylesAndroid.css}"/>

    Error: Position 6:10. Source property is not a string literal

Sign In or Register to comment.