Reputation: 3051
I know that to set a customized color for a property, we have to set it in style.xml file, but I want to have different color properties for each of my Xamarin.Forms page. How can I archive this?
<?xml version="1.0" encoding="UTF-8"?>
<resources>
<style name="MainTheme" parent="MainTheme.Base">
<item name="android:textAllCaps">false</item>
<item name="colorAccent">#000000</item>
<item name="colorControlActivated">#000000</item>
</style>
</resources>
Upvotes: 0
Views: 470
Reputation: 10938
In Xamarin.forms, you could set the resource for each page like below.
<ContentPage.Resources>
<ResourceDictionary>
<Style TargetType="xxx">
<Setter Property="" Value=""></Setter>
</Style>
</ResourceDictionary>
</ContentPage.Resources>
Or you could set the resource in App.xaml.cs:
<Application.Resources>
<ResourceDictionary>
<Color x:Key="color1">AliceBlue</Color>
</ResourceDictionary>
</Application.Resources>
And then use it in each page.
<ContentPage.Content>
<StackLayout BackgroundColor="{StaticResource color1}">
......
</StackLayout>
</ContentPage.Content>
Upvotes: 3