Silverlight 4 RIA服务DDS到ViewModel-自动完成所选项目绑定
我有一个 AutoCompleteBox,它使用 RIA DomainDataSource 来查询服务器。我需要将 AutoComplete.SelectedItem 绑定到 ViewModel.SelectedEmployee。它们共享相同的 DomainContext 和数据,但具有不同的查询。当我尝试以下操作时:
ViewModel.SelectedEmployee = autoCompleteBox1.ItemsSource; 我收到错误: 错误 1 无法将类型“System.Collections.IEnumerable”隐式转换为 HeadCount.Web.Employee',即它不起作用 - 我知道我可以共享查询,但由于我有一个非常大的数据源,这是不可能的。
我已经设法在数据网格和按钮内容中显示所选项目列,但只是无法弄清楚如何让应用程序理解它是相同的数据。我已经研究了几个小时了,需要一些信息,谢谢
I have an AutoCompleteBox that uses RIA DomainDataSource for the query to the server. I need to bind the AutoComplete.SelectedItem to the ViewModel.SelectedEmployee. They share the same DomainContext and data, but have different queries. When I try the following:
ViewModel.SelectedEmployee = autoCompleteBox1.ItemsSource;
I get the error:
Error 1 Cannot implicitly convert type 'System.Collections.IEnumerable' to HeadCount.Web.Employee' ie, it don't work-
I know I could share the queries, but since I have a very large data source this is not possible.
I have managed to display the selected item columns in a datagrid and a button content, but just cannot figure out how to make the app understand it is the same data. I have been at it for hours, need a little info Thx
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我找到了答案——演员阵容缺失。这行代码使它工作 - ViewModel.SelectedEmployee = autoCompleteBox1.SelectedItem as HeadCount.Web.Employee; –
I found the answer- a missing cast. This line of code made it work- ViewModel.SelectedEmployee = autoCompleteBox1.SelectedItem as HeadCount.Web.Employee; –