How can I set StyleSheet by platform?

LeonidProtsenkoLeonidProtsenko USMember ✭✭
edited February 17 in Xamarin.Forms

How can I set StyleSheet by platform?

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

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

Answers

  • LandLuLandLu Member, Xamarin Team Xamurai

    Try this:

    <ContentPage.Resources>
        <StyleSheet>
            <StyleSheetExtension.Source>
                <OnPlatform x:TypeArguments="x:Uri">
                    <On Platform="Android">/Assets/Android.css</On>
                    <On Platform="iOS">/Assets/iOS.css</On>
                </OnPlatform>
            </StyleSheetExtension.Source>
        </StyleSheet>
    </ContentPage.Resources>
    
  • LeonidProtsenkoLeonidProtsenko USMember ✭✭

    not works :smile:

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

    https://forums.xamarin.com/discussion/comment/364907#Comment_364907

  • gabzillagabzilla Member

    having same issue, i cant seem to find an answer everywhere on the net :(
    following @LandLu answer, i also got 'StyleSheet require either a Source or a content'

Sign In or Register to comment.