我有一个tab-control
包含三个选项卡项目。每个选项卡项目上都有一个datagrid
放置。并且这三个数据网格在其各自的选项卡项上都是 Master-Detail-SubDetail 形式。
当用户在主数据网格上选择一行时,如何从第一个选项卡项移动到第二个选项卡项?我使用ADO.Net
实体框架创建了一个模型来创建这个主从视图。
XAML 布局
<TabControl Height="270" HorizontalAlignment="Left" Margin="16,23,0,0" Name="tabControl1" VerticalAlignment="Top" Width="462">
<TabItem Header="Person" Name="tabItem1">
<Grid DataContext="{StaticResource peopleViewSource}">
<DataGrid AutoGenerateColumns="False" EnableRowVirtualization="True" Height="166" SelectedItem="{Binding personDetails}"
HorizontalAlignment="Left" ItemsSource="{Binding}" Margin="64,23,0,0" Name="peopleDataGrid" RowDetailsVisibilityMode="VisibleWhenSelected" VerticalAlignment="Top" Width="289">
<DataGrid.Columns>
<DataGridTextColumn x:Name="personIDColumn" Binding="{Binding Path=personID}" Header="person ID" Width="SizeToHeader" />
<DataGridTextColumn x:Name="firstNameColumn" Binding="{Binding Path=firstName}" Header="first Name" Width="SizeToHeader" />
<DataGridTextColumn x:Name="lastNameColumn" Binding="{Binding Path=lastName}" Header="last Name" Width="SizeToHeader" />
</DataGrid.Columns>
</DataGrid>
</Grid>
</TabItem>
<TabItem Header="Person Details" Name="tabItem2">
<Grid DataContext="{StaticResource peoplepersonDetailsViewSource}">
<DataGrid AutoGenerateColumns="False" EnableRowVirtualization="True" Height="120" SelectedItem="{Binding personDetails.personStatus}"
HorizontalAlignment="Left" ItemsSource="{Binding}" Margin="82,18,0,0" Name="personDetailsDataGrid" RowDetailsVisibilityMode="VisibleWhenSelected" VerticalAlignment="Top" Width="172">
<DataGrid.Columns>
<DataGridTextColumn x:Name="detailIDColumn" Binding="{Binding Path=detailID}" Header="detail ID" Width="SizeToHeader" />
<DataGridTextColumn x:Name="positionColumn" Binding="{Binding Path=position}" Header="position" Width="SizeToHeader" />
<DataGridTextColumn x:Name="personIDColumn1" Binding="{Binding Path=personID}" Header="person ID" Width="SizeToHeader" />
</DataGrid.Columns>
</DataGrid>
</Grid>
</TabItem>
<TabItem Header="Person Status" Name="tabItem3">
<Grid DataContext="{StaticResource peoplepersonDetailspersonStatusViewSource}">
<DataGrid AutoGenerateColumns="False" EnableRowVirtualization="True" Height="143" HorizontalAlignment="Left" ItemsSource="{Binding}" Margin="91,23,0,0" Name="personStatusDataGrid" RowDetailsVisibilityMode="VisibleWhenSelected" VerticalAlignment="Top" Width="185">
<DataGrid.Columns>
<DataGridTextColumn x:Name="detailIDColumn1" Binding="{Binding Path=detailID}" Header="detail ID" Width="SizeToHeader" />
<DataGridTextColumn x:Name="positionColumn1" Binding="{Binding Path=position}" Header="position" Width="SizeToHeader" />
<DataGridTextColumn x:Name="statussColumn" Binding="{Binding Path=statuss}" Header="statuss" Width="SizeToHeader" />
</DataGrid.Columns>
</DataGrid>
</Grid>
</TabItem>
</TabControl>