使用参数绑定 WPF 数据网格中的组合框
我有一个 DataGrid,模板列内有一个组合框。在该屏幕的其他地方,用户可以从单独的控件中进行“客户”选择。为了填充数据网格中的组合框,除了网格中每行的其他信息之外,我还需要将所选客户作为参数传递。
基本上...网格包含零件信息,组合框项目基于以下内容的组合:所选客户、零件编号和制造商。每行的组合框可能有不同的源列表。有没有办法可以在 XAML 中绑定该组合框的 ItemsSource?
I have a DataGrid with a combobox inside a template column. Elsewhere on this screen, the user makes a 'customer' selection from a separate control altogether. In order to populate the comboboxes in my datagrid, I need to pass in that selected customer as a parameter, in addition to other information from each row in the grid.
Basically... the grid contains part information, and the combobox items are based on a combination of the following: selected customer, part number, and manufacturer. Each row's combobox can potentially have a different source list. Is there a way I can bind the ItemsSource for that combobox in XAML?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我可能没有正确理解,但您可能有一个包含所有这些信息的对象,并将其绑定到组合框。
即
回复评论。
让从查询返回的行也位于上面提到的 ContextualInfo 中怎么样?然后您可以将 itemsource 绑定到它。您可以在 ContextualInfo 类的构造函数中运行查询。
I may not understand correctly, but you could possibly have an object that contains all that information together, and bind that to the combo box.
ie
In reply to comment.
How about having the rows returned from the query to also be in the ContextualInfo mentioned above? You can then bind the itemsource to that. You could potentially run the query in the constructor for the ContextualInfo class.