WPF-列表框-多重绑定操作指南
情况如下:
ListBox 有一个 ItemSource,它从表 A 中获取其显示和值数据:
Table A
ID Activity
1 Skiing
2 Hiking
3 Fishing
TableB 有一个人员列表
TableB
ID Name
1 Tom
2 Dick
3 Harry
TableC 是一个外部参照,它将人员列表及其首选活动连接起来......
TableC
UserID ActivityID
1 1
2 1
2 2
3 2
3 3
我最终想要什么显示是一个选中的列表框。当选择特定人员时,我想显示表 A 中的所有可用活动,并将该人员映射到的活动显示为选中状态。更好的是,我希望能够选择/取消选择各种活动,并通过数据绑定的现代奇迹,更新 TableC。
e.g.
Person: Harry
Activities:
_ Skiing
X Hiking
X Fishing
我知道我可以使用一些 SP 返回两列、活动以及活动是否映射到用户来完成此操作,但我想知道是否已经有一些内置方法可以实现这一点。
谢谢, 麦克风
Here's the situation:
ListBox has a ItemSource that gets its display and value data from Table A:
Table A
ID Activity
1 Skiing
2 Hiking
3 Fishing
TableB has a list of people
TableB
ID Name
1 Tom
2 Dick
3 Harry
TableC is an xref that joins up a list of people with their preferred activities...
TableC
UserID ActivityID
1 1
2 1
2 2
3 2
3 3
What I'd like to ultimately show is a CHECKED list box. When a specific person is selected, I'd like to display ALL the available activities from table A, with the activities to which the person is mapped shown as checked. Better still, I'd like to be able to select/de-select the various activities, and through the modern miracle of databinding, have TableC be updated.
e.g.
Person: Harry
Activities:
_ Skiing
X Hiking
X Fishing
I know I could pull this off using some an SP to return two columns, the activity, and if the activity is mapped to the user, but I'm wondering if there's already some built-in way to make this happen.
Thanks,
Mike
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我想我回答这个问题有点晚了,但仍然想提供帮助...您是否有一个业务层,它实际上以对象的形式存储这些表,例如成员集合和它们可以是的活动集合关联到?
如果是的话,那么就可以做到。另外,我假设该应用程序是在 WPF 中开发的。因此这里可以使用 MVVM 模式来提供简单的实现。
I guess I'm a bit late to answer the question, but still wanted to help... do you have a business layer which actually stores these tables in form of objects like a collection of members and a collection of activities which they can be associated to?
If yes, then it can be done. Also, I assume that the application is being developed in WPF. So the MVVM pattern can be used here to provide an easy implementation.