如何在Silverlight 3/WP7中使用类似于DynamicObject的东西? [英] How to use something similar to DynamicObject in Silverlight 3 / WP7?
问题描述
如何使用动态语言运行时(DLR)或其他方法在SILVERLIGHT 3(!)和WP7(无C#4.0!)中模仿System.Dynamic.DynamicObject..
How can you use Dynamic Language Runtime (DLR) or something else to mimic System.Dynamic.DynamicObject in SILVERLIGHT 3 (!) and WP7 (no C# 4.0!)..
我想做的是实现自动动态创建的数据绑定属性.
What I want to do is implement automatic dynamically created properties for databinding.
推荐答案
DLR可以与WP7一起使用.
Iron Ruby从版本1.1 支持Windows Phone 7.
The DLR can be used with WP7.
Iron Ruby supports Windows Phone 7 from version 1.1.
DynamicObject
可作为.Net 4.0之前的扩展
DynamicObject
was available as an extension prior to .Net 4.0
如果您乐于使用C#以外的语言,则可以选择.
在 http://msdn.microsoft .com/en-us/magazine/ff960707.aspx .
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")]
使框架能够解析绑定.
大概是从外部系统获取动态对象.您是否不能在应用程序和外部系统之间添加包装层,以将对象转换为POCO,而不是动态对象.
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.
这篇关于如何在Silverlight 3/WP7中使用类似于DynamicObject的东西?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!