user896692
user896692

Reputation: 2371

BackgroundColor for all windows

In my WPF-application, I want that the user can change the background color like he or she wants. How can I set the background color from the one window where I can set it to all windows in my app?

How can I manage this?

Upvotes: 1

Views: 213

Answers (2)

brunnerh
brunnerh

Reputation: 184296

You can dynamically reference (using DynamicResource) the same SolidColorBrush defined in the Application.Resources in the backgrounds of all windows, if you then replace this resource with another brush the windows will update.

Alternatively you could create a Brush property with change notifications somewhere (e.g. in some globally accessible settings in the App class) to which you can bind.

Upvotes: 2

ChrisBD
ChrisBD

Reputation: 9209

You don't say whether its a web or desktop app., nor whether you're using MVVM pattern or not, but I would suggest that you set this in the style sheet for your application. This is then referred to in the XAML for each "window".

Upvotes: 0

Related Questions