views:

26

answers:

1

If i have a Binding which has a property path and the data source can i execute it in code, to find the value?

The path that i am trying to follow can be quite complicated, including collection lookup and multiple levels.

there is a hack :

create a content control use BindingOperations.SetBinding()

then retrieve the content

is there a better way?

+1  A: 

You can avoid using a ContentControl, and write your own very simple class that derives directly from DependencyObject, and provides a single DependencyProperty, which you can then target with the binding. Aside from that, no, there isn't any better way - binding machinery in WPF is very much tied into the concept of dependency properties, and a binding cannot really be a "free-standing expression" that is just evaluated.

Pavel Minaev
thought so, but it never hurts to ask. thanks for the more efficient solution, ill derive straight from DP
Aran Mulholland