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!

Windows Presentation Foundation
Windows Presentation Foundation
A part of the .NET Framework that provides a unified programming model for building line-of-business desktop applications on Windows.
2,665 questions
{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