在控件/查询和演示元素之间移动数据的最新最佳方式是什么
我有几个组合框选项,用户可以在 WPF 窗口上进行选择。每个组合框都通过 EDMX 绑定到不同的表。组合不会相互绑定。
我正在寻找主/详细功能。当用户选择任何组合框选择(主)时,从选择(参数)构建的查询结果(详细信息)应显示在窗口的数据网格部分中。
数据网格没有明确定义,因为它将包含不同的数据,具体取决于从中选择的组合框。因此,对于我正在使用的数据网格:
<StackPanel Grid.Row="1" Height="167" Name="stackPanel4" VerticalAlignment="Top" DataContext="{StaticResource tbl_MyGenericDataGridViewSource}">
<DataGrid AutoGenerateColumns="True" Height="166" Name="dataGrid1" Width="760" ItemsSource="{Binding}" />
</StackPanel>
查询结果和数据网格之间的最佳数据缓存是什么?
我应该使用数据集吗?
这将是我可以在组合框选择事件或查询返回事件上绑定到数据网格的东西。我想利用 Framework 4.0 WPF 魔法来做到这一点。
I have several combobox choices which a user can select from on a WPF window. Each of those compbo boxes are bound to different tables through EDMX. The combos do not bind to eachother.
I'm looking for a master/detail functionality. When a user selects anyone of the combobox selections(master) a query results(details) built from the selection(parameter) should be displayed in a datagrid section of the window.
The datagrid is NOT explicitly defined as it will contain different data depending on which combobox was selected from. So for the datagrid I'm using:
<StackPanel Grid.Row="1" Height="167" Name="stackPanel4" VerticalAlignment="Top" DataContext="{StaticResource tbl_MyGenericDataGridViewSource}">
<DataGrid AutoGenerateColumns="True" Height="166" Name="dataGrid1" Width="760" ItemsSource="{Binding}" />
</StackPanel>
What is the best data cache between the query results and the datagrid?
Should I be using a dataset?
This would be something I can bind to the datagrid on a combobox selection event or query return event.I want to do this taking advantage of Framework 4.0 WPF wizardry.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我对 EDMX 一无所知。但要做到这一点,我将创建一个简单的视图模型类,该类公开
ParentDataView
、ChildDataView
和Text
属性,并填充它们的集合,然后执行如下操作:您可能还可以绑定到
DataTable
对象的集合,并将子数据网格的ItemsSource
上的绑定设置为类似 < code>SelectedItem.ChildRelations[0].ChildTable,但是如果表有多个子关系并且您不想使用第一个子关系,那么您就会有点搞砸了。此外,在视图模型类中创建 DataView 可以让您在需要时轻松实现排序和过滤命令。
I know nothing of EDMX. But to do this, I'd create a simple view model class that exposed
ParentDataView
,ChildDataView
, andText
properties, populate a collection of them, and then do something like this:You could probably also just bind to a collection of
DataTable
objects, and set the binding on the child data grid'sItemsSource
to a path likeSelectedItem.ChildRelations[0].ChildTable
, but then you'd be kind of screwed in the case where the table had multiple child relations and you didn't want to use the first one.Also, creating
DataView
s in your view model class gives you an easy path to implementing sorting and filtering commands when the time comes.