Welcome to Microsoft Q&A!
I changed the color of the foreground (text) color of a button, but when in app i hover over the button it switches to black (default). I tried to change focus color but with no success. Is there a way to make white text permanent for a default vs2022 button?
@Castorix32 's answer is correctly. He overrides the default brush for pointer over of all the button in the application resources. His soultion will change the foreground color of all the buttons in the app when pointer over.
I would like to share a similar solution for your requirement which you could try if you failed to use his soultion.
1) Create a default button style for the target button.
2) Find the
VisualStateManager.VisualStateGroups parts of the ContentPresenter inside the template.
3) Change the value for Foreground in the VisualState named
PointerOver. In my test, I changed it to yellow.
4) Add a VisualState named
Focused, then add
ObjectAnimationUsingKeyFrames to change the color when the button gets focused. In my test, I changed it to red.
5) Apply the style for the target button.
I failed to post the code in the answer. I added an attachment with the code that you could refer to. Please check the attachment and let me know if it works for you.
If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.