.NET – How to pass the converter parameters to non-hard coding

It’s like:

For example, when a person’s name is an attribute of the class.

Update:

I have seen a solution , Tell me to inherit DependencyObject and implement IValueConverter.
I want to know if there is something simpler.

The answer is straightforward, but not what you want to hear.

You can only locate the binding on the DependencyProperty on the DependencyObject. The binding does not inherit from DO, so you cannot bind Converter parameters.

If you wish to pass other states to the converter, you may have to subclass the required objects and add new attributes

Like:

< /pre> 

For example, when a person's name is an attribute of the class.

Update:

I have seen a solution that tells me to inherit DependencyObject and implement IValueConverter.< br>I want to know if there is something simpler.

The answer is straightforward, but not what you want to hear.

You can only locate the binding on the DependencyProperty on the DependencyObject. The binding does not inherit from DO, so you cannot bind the converter parameters.

If you wish to pass other states to the converter, You may have to subclass the required objects and add new attributes

Leave a Comment

Your email address will not be published.