Quantcast
Channel: Windows Presentation Foundation (WPF) forum
Viewing all articles
Browse latest Browse all 18858

How to bind so that a UI element is notified that it needs to update on any of multiple changes?

$
0
0

Given a UI element is bound to and displays a particular property in a class, how can that element be informed within the XAML scripting framework that it also needs to update given changes in one or more other properties?

We have a UI element that has a converter whose behavior is modified as a result of the state of a number of properties and depending upon the state of any of these properties will format the return value differently. However, the UI element itself, which uses this converter, is bound to a single property and thus only knows to update itself when the value of that property changes. Changes in any of the other properties consumed within the converter are ignored by the UI element.

For example, assume that the UI element is bound to PropDisplayedValue which is massaged by ConverterOfDisplayedValue which looks at the state of Prop2 and Prop3 to modify how PropDisplayedValue will be formatted for the UI element. Changes to Prop2 and Prop3 should trigger a refresh of the UI element. We've been getting around this by adding addition notifications to all of the possible conditions but this means that the properties themselves must have intimate knowledge about how they are being consumed plus it leaves us open to making mistakes. What would be better is if the UI element could subscribe to the Prop2 and Prop3 notifications as well as its PropDisplayedValue notification.


Richard Lewis Haggard


Viewing all articles
Browse latest Browse all 18858

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>