在 WPF 中,您可以绑定(bind) ExpandoObject 和其他动态类型:
dynamic o = new ExpandoObject();
o.Foo = "Hello";
DataContext = o;
<TextBlock Text="{Binding Foo}"/>
这在 Silverlight 5 中不起作用。有没有办法让它起作用,或者有人有这个问题的链接吗?
最佳答案
在 Silverlight 5 中,他们没有添加绑定(bind)到动态对象的默认机制,而是添加了一个新接口(interface) ICustomTypeProvider
.并且该接口(interface)也没有添加到 ExpandoObject 中,但是使用 expando 您应该能够使用索引器绑定(bind),因为它是 IDictionary<string, object>
实现 INotifyPropertyChanged
.
<TextBlock Text="{Binding [Foo]}"/>
关于silverlight - 在 Silverlight 中绑定(bind) ExpandoObject,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10887820/