I noticed that the Office 2016 theme is the only theme where the RadButton foreground and background colors get inverted on mouse hover.
Unfortunately, if I do this, the text stays black even on mouse hover:
The following 2 versions work:
But I cannot use the first because in reality the content I want to put in the button is more complex (TextBlock containing Run objects).
And the second would be a workaround which I would like to avoid as it is not the optimal way.
The reason it does not work is because the IsMouseOver trigger in the template does this:
By setting TextElement.Foreground on the ContentPresenter inside the control's template, only children that consider the ContentPresenter as their logical parent will inherit from its Foreground property.
- When using the ContentTemplate property, the elements within the DataTemplate become logicial descendents of the ContentPresenter, so the inheritence of the Foreground property works.
- When using the Content property, the logical parent of the topmost element that forms the content is not the ContentPresenter within the control's template, but the control (RadButton) itself. Therefore the foreground of the content will depend on the Foreground property of the control itself. The latter is not changed by the trigger, so it stays black, and so does the content's foreground.
The seemingly obvious fix would be to change the template trigger's setter to this:
If you feel like this is an appropriate fix, please include it in future versions so that we do not have to customize your template just for that.
If not, and you have advice, you're welcome share it.