
Hello members of the Actipro community!
I am using different themes in a customer application. The application has many views with textboxes.When a certain theme is activated, in this case "MetroDark", I have problems with the contrast of the textbox background (black) and the foreground color. Depending on the environmental lighting (sun), the content of the textboxes could be hard to read. So I should change the text color to white or something else so that the contrast becomes better.
The customer is advised to restart the application if the theme is changed.
I tried the following code to change the forground property of the textbox style when MetroDark is activated
ThemeManager.CurrentTheme = ThemeName.MetroDark.ToString();
Style style = newStyle();
style.TargetType = typeof(TextBox);
Style currentStyle = (Style)Application.Current.FindResource(typeof(TextBox));
foreach (var item in currentStyle.Setters)
{
if (((Setter)item).Property != TextBox.ForegroundProperty)
{
// add all other settings to the new style, except the foreground property
style.Setters.Add(item);
}
}
style.Setters.Add(newSetter(TextBox.ForegroundProperty, newSolidColorBrush(Colors.White)));
// remove the current style
if (Application.Current.Resources[typeof(TextBox)] != null)
{
Application.Current.Resources.Remove(typeof(TextBox));
}
// add the new style
Application.Current.Resources.Add(typeof(TextBox), style);
While checking the code, i have seen that the value of the foreground setter references the "ActiproSoftware.Windows.Themes.AssetResourceKeys.ToolBarEditForegroundNormalBrushKey".
As the code does not do anything, how or where can I change the color of the ToolBarEditForegourndNormalBrushKey resource in my code?
Thank you for your help.