forum

Home / DeveloperSection / Forums / How to bind to property of object returned by converter

How to bind to property of object returned by converter

Anonymous User184718-Jul-2013
HI mindstick!

I'm trying to bind to a value, run a converter over it, and then display a property of that value. Having the Converter directly return the property I want wouldn't work, as I need property changes to be tracked.

What I'm trying to achieve would be something like this:

// NOTE: FOLLOWING IS NOT SUPPORTED BY WPF

// A 'Binding' cannot be set on the 'Source' property of type 'Binding'.

// A 'Binding' can only be set on a DependencyProperty of a DependencyObject.

Text={Binding TextField Source={Binding SomeValue, Converter={StaticResource GetObjectFromValueConverter}}}`

Ideally, this would all be wrapped up in a simple markup extension.

Text={l:GetTextField SomeValue}

Problem is, I haven't been able to find any way to do this other than bind the Tag of the element to the converter, and then bind the target field to the property as follows:

Tag={Binding SomeValue, Converter={StaticResource GetObjectFromValueConverter}}

Text={Binding Tag.TextField, RelativeSource={RelativeSource Self}}

This is obviously cumbersome, limited (you only get one Tag field) and feels abusive. How else can I go about achieving what I want whilst monitoring for changes of TextField though?

thank in advance


Updated on 18-Jul-2013
I am a content writter !

Can you answer this question?


Answer

1 Answers

Liked By