Resources can be referred statically or dynamically. Static referred resources evaluate the resource only once and after that if the resources change those changes are not reflected in the binding. While dynamic referred resources are evaluated every time the resource is needed.
Consider the below “SolidColorBrush” resource which is set to “LightBlue” color.
<Window.Resources>
<SolidColorBrush Color="LightBlue" x:Key="buttonBackground" />
</Window.Resources>
The above resource is binded with the below two textboxes statically and dynamically respectively.
<TextBox Background="{DynamicResource buttonBackground}" /> <textbox background="{StaticResource buttonBackground}">
Now if we modify the resource , you see the first text box changes the background and the other textbox color stays as it is.
private void Button_Click(object sender, RoutedEventArgs e) { Resources["buttonBackground"] = Brushes.Black; }
Below is the output of the same.