<Window x:Class="TEST.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:TEST"
xmlns:p="clr-namespace:TEST.Properties"
Title="MainWindow" Width="800" Height="600">
<Grid>
<Label x:Name="label" Content="Test" HorizontalAlignment="Left" Margin="104,101,0,0" VerticalAlignment="Top" Background="{Binding Source={x:Static p:Settings.Default}, Path=SomethingsColor}" Height="107" Width="218"/>
</Grid>
</Window>
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
</startup>
<appSettings>
<add key = "SomethingsColor" value = "Black" />
</appSettings>
</configuration>
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
</startup>
<applicationSettings>
<TEST.Properties.Settings>
<setting name="SomethingsColor" serializeAs="String">
<value>#FF008000</value>
</setting>
</TEST.Properties.Settings>
</applicationSettings>
</configuration>
<Application.Resources>
<SolidColorBrush x:Key="solidGrayBrush" Color="Gray" />
<TextBlock
Background="{DynamicResource solidGrayBrush}"
Text="Test" />
Brush[] brushes =
typeof(Brushes)
.GetProperties()
.Select(p => (Brush)p.GetValue(null))
.ToArray();
Random r = new Random();
private void Button_Click(object sender, RoutedEventArgs e)
{
var b = brushes[r.Next(brushes.Length)];
Application.Current.Resources["solidGrayBrush"] = b;
}