Silverlight 4 RIA服务DDS到ViewModel-自动完成所选项目绑定

发布于 2024-08-23 01:26:13 字数 434 浏览 3 评论 0原文

我有一个 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

若有似无的小暗淡 2024-08-30 01:26:13

我找到了答案——演员阵容缺失。这行代码使它工作 - 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; –

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文