I want to apply a bunch of styles to a page controls upon some data, for example, if current ViewMode
is ReadOnly
, the save button becomes hidden, and the Entry
s are disabled, but if the ViewMode
is New
then the button becomes Visible
and the Entry
s are editable.
The pages I'm working on are full of controls, and much more complex than this axample, and currently what I do is that I apply DataTrigger
for every control that is affected by the ViewMode
, but this makes it hard to make changes to the code (maintainability).
so I thought if there is a better way to do this, for example having two styles, one for the New
and another for Readonly
modes, and the page picks the appropriate style and apply it to its controls, by binding some property on the ContentPage
to the ViewMode
and with a converter, the appropriate style is returned (or a DataTrigger
).
I know this all is inapplicaple in XF, for example I'll have to create a style for every control, and the page may have two ResourceDictionary
s and in code-behind I set only one ResourceDictionary
based on the ViewMode
.. but this is a lot of code for a simple purpose!
Any other better approach?