-
-
Notifications
You must be signed in to change notification settings - Fork 132
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Dark Theme and dynamically added control #107
Comments
Hi, you must change the background color on code or enable "enforce back color" as in this wiki entry https://github.com/leocb/MaterialSkin/wiki/FAQ#backcolor-property-on-non-material-components |
Hey, both of those solutions are not working, the "EnforceBackColor" is already set to true, and copying the designer code doesn't work either. I suspect this is a bug due to the order in which the controls are colored and added ? |
The flow layout may be breaking something, could you try adding the panel directly to the form? |
I tried with a tabControl and also by adding it directly to the form, and still have the same behavior ! |
Weird, are you overriding the onPaint function on your control? |
I'm not overriding the onPaint function no, and it doesn't work with a simple panel ! |
I manage to solve this issue by calling the AddFormToManage function or setting the theme after dynamically adding the control, since those functions calls the private UpdateBackgrounds function. Though, this is not ideal because in the case of a desktop App i'm working on, controls are added after all of the form management function are called. May I suggest adding a public function to MaterialSkinManager to be able to force the background on a newly added control ? I can work on this and make a PR if you think that's the best approach ! |
Maybe the best option would be to add a public function to MaterialSkinManager to set the background color on a specific control, and then add an event listener on the MaterialForm itself to check for ControlAdded and apply the correct Background on it ! |
Thanks for the fix! |
No problem ! |
Hi,
I'm running into a strange and really specific issue with the dark theme.
When creating a custom control with a panel, and adding it in designer mode into a Form, everything works fine with dark mode. But if I had it by script, then it seems like the MaterialSkinManager cannot access the custom control background and leave it white.
This is how I had the custom control :
CustomControl customControl = new CustomControl(); flowLayoutPanel.Controls.Add(customControl);
You can see below a picture illustrating this behavior, on the left the custom control added from designer mode, and on the right the one added by script.
Any idea on why this is happening would be appreciated, maybe I need to force the background manually ?
Thanks !
The text was updated successfully, but these errors were encountered: