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:

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

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.

Answers

Sign In or Register to comment.