Replies: 2 comments 1 reply
-
|
Hi trebahl, unfortunately the most straight forward solution by adding an implicit Style with TargetType Window to the Resources Tag in App.xaml like this does not get applied at runtime (no idea if this was done on purpose by the WPF team), though it interestingly seems to get recognized by Visual Studio's Designer. - The explicit one
All your property setters meant for all Windows are in 1 place (App.xaml) and it just needs 1 line per Window to apply them. - The more implicit one
In this solution you don't need a keyed style. An implicit one with TargetType being your custom BaseWindow is enough.
Its code behind class looking something like this: WPF will look up the style for your custom Window class BaseWindow in the Generic.xaml file and automatically apply it to all instances of BaseWindow without the need to set the Style explicitly like in the first workaround. Another advantage of this solution is that it gives you even more flexibility by enabling you to customize your BaseWindow even more since it is a full blown custom control. I hope some parts are applicable to your project and code structure. Best wishes from Germany |
Beta Was this translation helpful? Give feedback.
-
|
Thanks, but I want to avoid static variables as much as I can, so using the Application class is a no go for me. Also I would like to change the values dynamically; I guess it might be possible to search for the styles in the global resource dicitionaries and modify them, but it would be very convoluted compared to just setting a new value on the parent window. I guess I'll just explictly bind properties from parent windows to child window. There has to be another way though: in avalon dock, the autohide panels are placed in separate windows, that do receive the fontsize of the main window. But I failed to understand how they do it. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
I would have expected inheritable properties set on a window to be inherited by its owned windows, but it seems that isn't the case.
I guess I could define explicitly a binding for every property I'm interested in (mostly FontSize TBH), but I was wondering if there was a more direct solution.
Beta Was this translation helpful? Give feedback.
All reactions