Silverlight并绑定​​到匿名类型 [英] Silverlight and binding to anonymous types

查看:123
本文介绍了Silverlight并绑定​​到匿名类型的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

ScottGu承认:旧帖子数据绑定到匿名类型只是工作,因为匿名类型只是语法糖(无论什么意思),从CLR的角度来看,它们都是一个真正的类型,写一下。



不过Mike Hillberg 帖子,这不是silverlight的情况,根据我的经验,我会同意他---但是我希望斯科特是正确的,因为建立这些所谓的名义类型是我认为匿名类型解放我们的。



有人可以解释为什么,在这种情况下的Silverlight绑定到匿名类型不会飞。

解决方案

Hillberg是正确的,在Silverlight中你不能绑定到匿名类型。真的可惜,它会解决各种问题,但你会去。



Silverlight中的绑定取决于Reflection,它只支持反映公共类型。由于匿名类型是内部的,匿名类型不能用于绑定。



为什么Silverlight不能反映内部类型?邓诺,我也想知道。


ScottGu indicated in an admittedly old post that databinding to anonymous types "just works" because anonymous types are just "syntactic sugar" (whatever that means) and from the CLR perspective they are every bit as real a type as anything I would write up.

However Mike Hillberg posts that such is not the case with silverlight, and in my experience I would agree with him --- however I wish Scott was right, as building these so-called "nominal types" is what I thought anonymous types liberated us from.

Could somebody please explain why, in the case of Silverlight binding to anonymous types doesn't fly.

解决方案

Mike Hillberg is correct, in Silverlight you cannot bind to anonymous types. A real pity cause it would solve all sorts of problems but there you go.

Binding in Silverlight depends on Reflection and it only supports Reflecting on public types. Since Anonymous types are internal, anonymous types can't be used in binding.

Why can't Silverlight reflect on internal types? Dunno, I'd like to know too.

这篇关于Silverlight并绑定​​到匿名类型的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆