I have a resource dictionary as follows,
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:uwpControls="using:Microsoft.Toolkit.Uwp.UI.Controls" xmlns:controls="using:Presentation.Common.Controls"> <Style x:Key="ExpanderStyleSection" TargetType="uwpControls:Expander"> <Setter Property="HeaderStyle" Value="{StaticResource LightExpanderHeaderToggleButtonStyle}"/> <Setter Property="Margin" Value="4"/> </Style> <Style x:Key="LightExpanderHeaderToggleButtonStyle" TargetType="ToggleButton"> <Setter Property="Template"> <Setter.Value> <ControlTemplate TargetType="ToggleButton"> <Grid x:Name="RootGrid" Background="{StaticResource BrushBeckmanAquaA1}"> <!-- I want to change the background from an other View based on some condition --> </ControlTemplate> </Style> </ResourceDictionary> Now I am using the style inside this Dictionary as follows in an other view.
<uwpControls:Expander x:Name="ExpanderLisSharedSettings" Grid.Row="0" Style="{StaticResource ExpanderStyleSection}"> <!--Some Content here--> </uwpControls:Expander Whenever a property in the ViewModel changes, I want to update the RootGrid background in the ControlTemplate to some other color. How can I do it? In other words is there a way to create a dependency property of type Brush color and bind to the RootGrid Background in the ResourceDictionary. Please help.