Skip to content
This repository has been archived by the owner on Jun 2, 2023. It is now read-only.

Cannot change control background color #17

Open
mpoelzl opened this issue Mar 18, 2019 · 3 comments
Open

Cannot change control background color #17

mpoelzl opened this issue Mar 18, 2019 · 3 comments

Comments

@mpoelzl
Copy link

mpoelzl commented Mar 18, 2019

Hello!
When using the blend theme I am unable to change the background color for individual controls. For example If I explicitly set a textbox Background to Red in xaml, the control will be shown in red in the editor preview but at runtime the textbox has the standard background color.

I did a bit of testing and the color that's actually being used is the background color of the ScrollViewer. So if I go and change the scrollviewer style in the Styles.xaml file then that color will be shown.

Any ideas why this is and how we can change it so that the background color can be overridden?

Thanks!

Mike

@mpoelzl
Copy link
Author

mpoelzl commented Mar 18, 2019

Ok, so after a bit of experimenting it appears to work if I add the 'Background' property to the ScrollViewer in the TextBox style's control template and set to 'TemplateBinding Background'.

Is this the right way to go about it (other controls would also need this)?

@DanPristupov
Copy link
Owner

DanPristupov commented Mar 18, 2019

It should be correct, however I'm not 100% sure because the code was written long time ago.

You can confirm that by generating a default WPF template and check the original approach.

If you want to update the background color everywhere, then you probably should do it like that:

<SolidColorBrush x:Key="ScrollViewerBackground" Color=“Red” />

@mpoelzl
Copy link
Author

mpoelzl commented Mar 18, 2019

In fact I think it's easier to just get rid of the Background setter in the scrollviewer style.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants