How I do change WPF background color with xaml style?

Roberto Carrer 1 Reputation point
2021-07-01T12:27:38.697+00:00

Hi.

In my WPF test project I tried to make the style dynamically changeable through a combobox. Everything works except the background color of the windows.

I have tried with StaticResource, with SolidColorBrush, with the same name, with different name of static resource but it does not work!

Can you help me?

The source code is here.
https://github.com/reddevlab/WpfCambioStile
Thank you!

Developer technologies Windows Presentation Foundation
{count} votes

1 answer

Sort by: Most helpful
  1. Roberto Carrer 1 Reputation point
    2021-07-02T09:17:45.16+00:00

    Hi. TryFindResource always return null!
    Your solution not solve my problem.

    I have resolved my problem changing from StaticResource to DynamicRecource.

    See the Git repository for solution.

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.