How to use something similar to DynamicObject in Silverlight 3 / WP7?

醉酒当歌 提交于 2019-12-06 07:39:48

The DLR can be used with WP7.
Iron Ruby supports Windows Phone 7 from version 1.1.

DynamicObject was available as an extension prior to .Net 4.0

If you're happy using a language other than C# then this could be an option.
There's a good article on using IronRuby on Windows Phone 7 at http://msdn.microsoft.com/en-us/magazine/ff960707.aspx.

As an alternative, could you use anonymous types, rather than dynamic ones? I assume that there isn't an infinite number of options you're potentially binding to.

If you do want to use anonymous types you must set

[assembly: System.Runtime.CompilerServices.InternalsVisibleTo("System.Windows")]

to enable the framework to resolve the bindings.

Presumably you're getting you dynamic objects from an external system. Could you not add a wrapper layer between your app and the external system to turn the objects into POCOs rather than dynamic objects.

As you mentioned, DLR with .Net 4.0 and C# 4.0 is not available in WP7. It means you can't do it. At least not easily.

Silverlight does not allow custom markup extensions (things between {}). So, that's not an option as well.

What you could do is create custom Behaviors for binding and make them work with Dictionaries that can hold as many properties and values.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!