What is Best Practice for Styling and Theming?

lcm98lcm98 Member ✭✭
edited June 2018 in Xamarin.Forms

Hey guys, so a pretty basic question here, I'm overhauling the look of my app from scattered resource dictionaries in different places along with applying specific properties in xaml throughout to something more cohesive and maintainable. I've read the docs on themes and styles, but just want to ask some clarifying questions to make sure I follow the norm. I handle all of my page creation with Xaml (as opposed to code behind), but my code sharing is .Net Standard if that matters.

I was wondering what the best practice in terms of methodology for this kind of thing is. The obvious answer would seem to be Xamarin Themes, but that's been in pre-release for 2 years, I've even seen someone somewhere claim it was abandoned, and so I'm just not sure it's a fully supported thing that I should be relying upon at this point.

The other option would then just be to define a master list of styles in the App Resource Dictionary I guess? Basically just have colors defined there, and then work off of those to make a big collection of all the different styles I want (how to support dark vs light settings? Are there any app settings that would set night modes or anything that need to be respected?) and use those throughout.

So any input on what's considered Best Practice to point me in the right direction would be greatly appreciated, thanks in advance for any and all help!

Answers

  • robbitrobbit CNMember Xamurai
    edited June 2018

    Hi @Icm98,

    About Xamarin.Forms Styles, you can read official document:

    Xamarin.Forms applications often contain multiple controls that have an identical appearance. For example, an application may have multiple Label instances that have the same font options and layout options.

    Styles often is used to handle the above scenes. That means if your MainPage's label has the same style with your SecondPage's label, you can extract it as a style, and put it as Application's resource.


    About Theme, it is usually used to define the overall style of the page.

Sign In or Register to comment.