I'm trying to give user a possibility to change color of the application. I'm using WPF Extended Toolkit to get Color and then save it into Settings so when I run again it, color will be applied. The problem is that for Rectangle it works perfectly but for Label and it background, when I run application again it turns automaticly white instead to saved Color. Here's my code:
Options class and xaml
public Options(MainWindow main)
{
InitializeComponent();
window = main;
BackgroundColor.SelectedColor = (Color)ColorConverter.ConvertFromString(Settings.Default.Main_Background);
TopBarBackColor.SelectedColor = (Color)ColorConverter.ConvertFromString(Settings.Default.Main_TopBack);
}
private void Color_SelectedColorChanged(object sender, RoutedPropertyChangedEventArgs<Color> e)
{
Settings.Default.Main_Background = BackgroundColor.HexadecimalString;
Settings.Default.Main_TopBack = TopBarBackColor.HexadecimalString;
Settings.Default.Save();
window.ColorChange(Settings.Default.Main_Background, Settings.Default.Main_TopBack);
}
MainWindow where I have label(TopBarMain) and rectangle(Background)
public void ColorChange(String _Main_B, String _Main_TopBar)
{
var converter = new BrushConverter();
try
{
Background.Fill = (Brush)converter.ConvertFromString(_Main_B);
TopBarMain.Background = (Brush)converter.ConvertFromString(_Main_TopBar);
}
catch (Exception e)
{
MessageBox.Show(e.Message);
Background.Fill = (Brush)converter.ConvertFromString("#E5EEEEEE");
TopBarMain.Background = (Brush)converter.ConvertFromString("#7FC3C3C3");
}
}
And I call it like this then running an application:
public MainWindow()
{
InitializeComponent();
ColorChange(Settings.Default.Main_Background, Settings.Default.Main_TopBack);
option = new Options(this);
}
Where option is:
Options option;
To call Options class. I have no clue anymore where is the problem. Please help.