我正在使用选项卡控件,并且我的选项卡控件中有两个选项卡,然后每个选项卡中有一个数据网格。但是,现在我可以在第一个数据网格中选择行,但不能在第二个中选择行。我不知道为什么我不能选择第二个数据网格中的行。
下面是我的xaml:
<TabControl Height="547" HorizontalAlignment="Left" Margin="12,14,0,0" Name="ManageTab" VerticalAlignment="Top" Width="768" Grid.RowSpan="2"
SelectionChanged="ManageTab_SelectionChanged">
<TabItem Header="STUT" Name="tab1">
<Grid Height="520" Width="765" DataContext="{StaticResource UserViewSource}">
<DataGrid AutoGenerateColumns="False" EnableRowVirtualization="True" Height="514" HorizontalAlignment="Left"
ItemsSource="{Binding}" Name="UserDataGrid" RowDetailsVisibilityMode="VisibleWhenSelected"
AlternatingRowBackground="LightBlue" VerticalContentAlignment="Center"
HorizontalGridLinesBrush="Gray" VerticalGridLinesBrush="Gray"
VerticalAlignment="Top" Width="346" SelectedCellsChanged="UserDataGrid_SelectedCellsChanged">
<DataGrid.Columns>
<DataGridTextColumn x:Name="AccColumn" Binding="{Binding Path=Acc}" Header="Account" Width="80" IsReadOnly="True" />
<DataGridTextColumn x:Name="NameColumn" Binding="{Binding Path=Name}" Header="Name" Width="80" IsReadOnly="True" />
</DataGrid.Columns>
</DataGrid>
<Button Content="Exit" Height="49" HorizontalAlignment="Left" Margin="669,0,0,110" Name="btnExit" VerticalAlignment="Bottom" Width="75" Click="btnExit_Click" />
</Grid>
</TabItem>
<TabItem Header="CLASS" Name="tab2">
<Grid Height="508" Width="753" DataContext="{StaticResource ClassViewSource}">
<DataGrid AutoGenerateColumns="False" EnableRowVirtualization="True" Height="514" HorizontalAlignment="Left"
ItemsSource="{Binding}" Margin="6,2,0,0" Name="ClassDataGrid" RowDetailsVisibilityMode="VisibleWhenSelected"
AlternatingRowBackground="LightBlue" VerticalContentAlignment="Center"
HorizontalGridLinesBrush="Gray" VerticalGridLinesBrush="Gray"
VerticalAlignment="Top" Width="342" SelectedCellsChanged="ClassDataGrid_SelectedCellsChanged">
<DataGrid.Columns>
<DataGridTextColumn x:Name="ClassNameColumn" Binding="{Binding Path=ClassName}" Header="ClassName" Width="280" />
</DataGrid.Columns>
</DataGrid>
<Button Content="Exit" Height="49" HorizontalAlignment="Left" Margin="672,0,0,178" Name="btnExit2" VerticalAlignment="Bottom" Width="75" Click="btnExit_Click"/>
</Grid>
</TabItem>
</TabControl>