In a C # project, I have a complex model that uses many classes nested in lists and dictionaries (for example, object A has a list of instances of B that have a dictionary, where values โโare instances of C ). On one of my pages this model is shown in a complex form using nested ItemsControl s.
In addition, there is a Settings class that stores user settings, some of which are tied to checkboxes on the page.
Now I want to bind the properties of some controls in the DataTemplate to a combination of model properties and customization. For example, suppose C has the IsBoring property, and there are Settings.HideBoringStuff settings. I want to bind the visibility of a TextBlock representing C to an obvious combination of these properties.
I don't know how to do this without ugly hacks. Here are some of my ideas and why they do not work:
Use MultiBinding , which is specifically designed for this. However, MultiBinding not available in UWP projects.
Bind to several properties of a page that implements logic in its getters and setters. This does not work because I'm inside a DataTemplate , so I need several independent copies of this logic.
Use Converter to convert a model property by passing ConverterProperty as a parameter. However, ConverterProperty n o DependencyProperty and therefore cannot be bound.
Create the necessary properties directly in model - Settings anyway. This seems very ugly as I will mix unnecessary dependencies and consider the logic in my model.
Create separate classes that wrap model classes, also save the Settings object for use, and then offer combined properties. It also seems very ugly, since I will need to replicate the entire hierarchy of model objects. (In the ViewA example, a list of ViewB s should be presented, each of which has a dictionary, where the values โโcorrespond to ViewC s.)
Wait for Microsoft to bring MultiBinding back. Unfortunately, I lack the necessary optimism.
What are the clean ways to do this in a UWP app?
source share