Setting the color dynamically for an element using a resource is done in the following way:
XAML
<ContentPage BackgroundColor="{DynamicResource backgroundcolor}"/>
Code behind:
App.Current.Resources["backgroundcolor"] = Color.Green;
The above code will change the backgroundcolor of the contentpage to green.
How can I dynamicaly change the colors of the new Shell tapbar if I declared the style as follows:
<Shell...> <Shell.Resources> <Style x:Key="BaseStyle" TargetType="Element"> <Setter Property="Shell.BackgroundColor" Value="#455A64" /> <Setter Property="Shell.ForegroundColor" Value="{DynamicResource backgroundcolor}" /> <Setter Property="Shell.TitleColor" Value="#700606" /> <Setter Property="Shell.DisabledColor" Value="#B4FFFFFF" /> <Setter Property="Shell.UnselectedColor" Value="Gray" /> </Style> </Shell.Resources> <TabBar Route="animals" Title="Animals" FlyoutDisplayOptions="AsMultipleItems"> <ShellContent Route="mainpage" Style="{StaticResource BaseStyle}" Title="Icon" Icon="Icon.png" ContentTemplate="{DataTemplate rv:MainPage}" /> </TabBar> </Shell>