Closed ividyon closed 5 months ago
For anyone else looking for this:
It seems to have happened because I was not using UserControl
as the parent of my new controls. I tried to create shortcuts and change the parent element to something like ContentControl
, and that is what was causing the breakage.
Putting a ContentControl child into a UserControl and manipulating that instead seems to restore all the resource inheritance, since apparently InitializeComponent()
in UserControl is what applies the resources.
I have code like this:
based on the Avalonia ViewLocator class.
Unfortunately it seems that any elements created in this way do not have the AdonisUI styling properly applied. They appear incorrect at first render.
As you can see, the text in the middle is black instead of white, as it should be in the dark mode theme.
Now, if I press my button which triggers a Dark Mode toggle, on/off...
The text appears correctly again!
But until then it is incorrect.
How could I avoid this and have it render correctly right away?