I'm working on an application, and I'm using the MVVM approach.
Basically, there are currently two Page
s, and 1 MainWindow
.
I switch between the pages using a Frame
inside MainWindow
.
In the main window, there are 2 buttons which are basically global and should show in all pages; x (exit) and settings.
This is basically my 'shell', as I decided to not use a window border.
The problem is I'd like each page to have a different background and this is where it gets complicated:
- Settings page: Grey background.
- Main Page: Rotating background color that changes according to a property.
The thing is the background is being set in the main window, because it should apply to the global area as well (the top, where the exit and settings buttons are).
I first set the background (in MainWindow
) as bound to a property the represents the current page (the value is then being translated into a color hex code with the help of a converter).
All in all, this results in a case where the background changes when a page is changed, but not when the property inside MainPage
changes. I can clearly understand why, but I have no idea how to solve it.
The possible solutions I came up with so far:
- Somehow causing the binding in
MainWindow
to update/refresh when the property is changed inMainPage
. - Changing the background manually from inside each of the pages. (Although doesn't it negate the idea of mvvm?)
- Move the background into each of the pages and set it from there, while making the global buttons on top of the page (which could be a bad thing in case controls end up overlapping).
If so, what would be the best solution to this problem?