fefrei
fefrei

Reputation: 905

Bind to multiple Properties in UWP

In a C# project, I have a complex model using lots of classes nested in lists and dictionaries (e.g. object A has a list of instances of B, which have a dictionary where values are instances of C). In one of my pages, this model is shown in a complex view using nested ItemsControls.

In addition, there is a Settings class which stores user preferences, some of which are bound to checkboxes on the page.

Now, I want to bind properties of some controls within the DataTemplates to a combination of a model property and a setting. For example, let's say that C has a property IsBoring, and there is a settings Settings.HideBoringStuff. I want to bind the visibility of the TextBlock representing C to the obvious combination of these properties.

I have no idea how to do that without ugly hacks. Here are a few of my ideas and why they don't work:

Which are clean ways to do this in a UWP application?

Upvotes: 5

Views: 2319

Answers (1)

Depechie
Depechie

Reputation: 6142

True that Multibinding hasn't been around on the new win dev stacks. BUT Cimbalino toolkit has had it since early wp8 days. It also has an UWP port.

So maybe try that!

Blogpost from the early days explaining the use: https://www.pedrolamas.com/2013/05/17/cimbalino-windows-phone-toolkit-multibindingbehavior/ Getting hold of Cimbalino is done through nuget and is available on Github here https://github.com/Cimbalino/Cimbalino-Toolkit

Upvotes: 4

Related Questions