Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/sorting/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Wpf 在控件/查询和表示元素之间移动数据的最新最佳方式是什么_Wpf_Datagrid_Master Detail - Fatal编程技术网

Wpf 在控件/查询和表示元素之间移动数据的最新最佳方式是什么

Wpf 在控件/查询和表示元素之间移动数据的最新最佳方式是什么,wpf,datagrid,master-detail,Wpf,Datagrid,Master Detail,我有几个组合框选项,用户可以在WPF窗口中进行选择。每个compbo框都通过EDMX绑定到不同的表。这些组合彼此不绑定 我正在寻找主/细节功能。当用户选择任意组合框选项(主选项)时,根据选项(参数)生成的查询结果(详细信息)应显示在窗口的datagrid部分 datagrid没有明确定义,因为它将包含不同的数据,具体取决于从哪个组合框中选择。因此,对于我使用的datagrid: <StackPanel Grid.Row="1" Height="167" Name="stackPanel4"

我有几个组合框选项,用户可以在WPF窗口中进行选择。每个compbo框都通过EDMX绑定到不同的表。这些组合彼此不绑定

我正在寻找主/细节功能。当用户选择任意组合框选项(主选项)时,根据选项(参数)生成的查询结果(详细信息)应显示在窗口的datagrid部分

datagrid没有明确定义,因为它将包含不同的数据,具体取决于从哪个组合框中选择。因此,对于我使用的datagrid:

<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>

查询结果和datagrid之间的最佳数据缓存是什么?
我应该使用数据集吗


这将是我可以在组合框选择事件或查询返回事件上绑定到datagrid的东西。我想利用Framework 4.0 WPF向导来实现这一点。

我对EDMX一无所知。但要做到这一点,我需要创建一个简单的视图模型类,公开
ParentDataView
ChildDataView
Text
属性,填充它们的集合,然后执行如下操作:

<ComboBox x:Name="selectTable" 
          ItemsSource="{Binding {StaticResource TableCollection}"             
          DisplayMemberPath="Text"/>
<DataGrid ItemsSource="{Binding ElementName=selectTable, Path=SelectedItem.ParentDataView}"/>
<DataGrid ItemsSource="{Binding ElementName=selectTable, Path=SelectedItem.ChildDataView}"/>

您也可以只绑定到
DataTable
对象的集合,并将子数据网格的
ItemsSource
上的绑定设置为类似
SelectedItem.ChildRelations[0]的路径,但是,如果表有多个子关系,而您不想使用第一个子关系,那么您就有点麻烦了


另外,在视图模型类中创建
DataView
s,可以方便地在适当的时候实现排序和筛选命令。

我对EDMX一无所知。但要做到这一点,我需要创建一个简单的视图模型类,公开
ParentDataView
ChildDataView
Text
属性,填充它们的集合,然后执行如下操作:

<ComboBox x:Name="selectTable" 
          ItemsSource="{Binding {StaticResource TableCollection}"             
          DisplayMemberPath="Text"/>
<DataGrid ItemsSource="{Binding ElementName=selectTable, Path=SelectedItem.ParentDataView}"/>
<DataGrid ItemsSource="{Binding ElementName=selectTable, Path=SelectedItem.ChildDataView}"/>

您也可以只绑定到
DataTable
对象的集合,并将子数据网格的
ItemsSource
上的绑定设置为类似
SelectedItem.ChildRelations[0]的路径,但是,如果表有多个子关系,而您不想使用第一个子关系,那么您就有点麻烦了

此外,在视图模型类中创建
DataView
s,可以方便地在适当的时候实现排序和过滤命令