Forum Xamarin.Forms
We are excited to announce that the Xamarin Forums are moving to the new Microsoft Q&A experience. Q&A is the home for technical questions and answers at across all products at Microsoft now including Xamarin!

We encourage you to head over to Microsoft Q&A for .NET for posting new questions and get involved today.

How to switch Theme using Xamarin.Forms Themes

JunZhang.6593JunZhang.6593 USMember ✭✭
edited July 2016 in Xamarin.Forms

Hi Folks,

Xamarin Forms 2.3 introduced Theme
I have code below in App.xaml.cs:

    <!-- Theme 1 -->
        <Style TargetType="Label" Class="DefaultLabel">
            <Setter Property="FontSize" Value="Large"/>
            <Setter Property="TextColor" Value="White"/>
    <!-- Theme 2 has the same DefaultLabel but with Medium FontSize and Black TextColor, but HOW? -->

But how do I switch to a new theme, so that all Labels whose StyleClass="DefaultLabel" in the new theme will have medium FontSize and black TextColor?
I know I could use Dynamic Resource, but that means I have to reset each Control in the app to the new Style.
What I wanna do is that only switch the theme name for the app, so that all Controls in the app are referring to a completely different set of Styles.

Thank you in advance.


Sign In or Register to comment.