0

I have a control which uses the old-style data biding via *MemberPath properties. However, my situation requires the usage of a DynamicObject. When you get the type of that dynamic object and call GetProperty(..) it returns null (because the object itself does not contain such a property - it is a dynamic one). So.. how can I solve this issue? How can I bind an object with dynamic properties having that the view uses that old-style data binding approach?

1 Answer 1

1

You're somewhat out of luck in Silverlight 4. Silverlight 5 (in beta) has the ICustomTypeProvider interface to allow binding to dynamic properties, but Silverlight 4 doesn't have this. Until Silverlight 5 is released, you have two options:

1) Write a value converter to get the value from the object.

OR

2) Have an indexer on your object that when passed a "property" name, returns the corresponding value. You can then extract the value like so:

Binding="{Binding [PropertyName]}"

Option 2 is the best option IMO.

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks for your reply. Unfortunately I cannot use binding like this, because I have *MemberPath properties (which in the background call obj.GetType().GetProperty(...))

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.