【发布时间】:2008-11-15 17:38:27
【问题描述】:
启动一个新的 Silverlight 应用程序...并在后面的代码中(在“已加载”事件中)输入以下代码:
// This will *NOT* cause an error.
this.LayoutRoot.DataContext = new string[5];
但是……
// This *WILL* cause an error!
this.LayoutRoot.DataContext = this;
引发的错误是“值不在预期范围内”。顺便说一句,此代码在常规 WPF(Windows 开发)中 100% 工作,应该没有理由不能在 WPF/E 中工作:)
有什么想法吗?
【问题讨论】:
标签: wpf silverlight data-binding datacontext