我是 wpf 的新手。我正在开发一个新的应用程序。在我的应用程序中,我使用选项卡控件。使用了两个选项卡项。在一个选项卡项数据网格用于显示。单击数据网格行时,我想将焦点设置到下一个选项卡项。
在 Row_DoubleClick 上,代码如下...
if (dgMain.SelectedItem == null)
return;
cardType = ((Entity.CardType)dgMain.SelectedItem);
txtCardType.Text = cardType.card_type_desc;
tabMain.SelectedItem = tbiConfig;
此代码不起作用。焦点没有移动到另一个选项卡。
各位,能帮帮我吗?
------ xaml如下
<Grid>
<Label Content="Card Type" Height="35" HorizontalAlignment="Left" Margin="17,12,0,0" Name="lblHeader" VerticalAlignment="Top" FontSize="18" Width="193" />
<TabControl Height="235" HorizontalAlignment="Left" Margin="12,53,0,0" Name="tabMain" VerticalAlignment="Top" Width="576">
<TabItem Header="Configure" Name="tbiConfig">
<Grid>
<Button Content="Save" Height="23" HorizontalAlignment="Left" Margin="450,137,0,0" Name="btnSave" VerticalAlignment="Top" Width="75" Click="btnSave_Click" />
<Label Content="CardType" Height="28" HorizontalAlignment="Left" Margin="14,34,0,0" Name="lblCardType" VerticalAlignment="Top" />
<TextBox Height="23" HorizontalAlignment="Left" Margin="130,36,0,0" Name="txtCardType" VerticalAlignment="Top" Width="395" />
</Grid>
</TabItem>
<TabItem Header="Search" Name="tbiSearch">
<Grid HorizontalAlignment="Stretch" VerticalAlignment="Stretch">
<Label Content="CardType" Height="28" HorizontalAlignment="Left" Margin="10,10,0,0" Name="lblSearchCardType" VerticalAlignment="Top" />
<TextBox Height="23" HorizontalAlignment="Left" Margin="126,12,0,0" Name="txtSearchCardType" VerticalAlignment="Top" Width="333" />
<Button Content="Search" Height="23" HorizontalAlignment="Left" Margin="473,12,0,0" Name="btnSearch" VerticalAlignment="Top" Width="75" Click="btnSearch_Click" />
<DataGrid AutoGenerateColumns="false" Height="148" HorizontalAlignment="Left" Margin="15,49,0,6" Name="dgMain" VerticalAlignment="Center" Width="533" ItemsSource="{Binding}" CanUserAddRows="True" GridLinesVisibility="All" HorizontalGridLinesBrush="LightGray" IsEnabled="True" IsReadOnly="True" RowHeight="23" HorizontalContentAlignment="Left" VerticalGridLinesBrush="LightGray" VerticalContentAlignment="Center" MouseDoubleClick="dgMain_MouseDoubleClick">
<DataGrid.ItemContainerStyle>
<Style TargetType="DataGridRow">
<EventSetter Event="MouseDoubleClick" Handler="Row_DoubleClick"/>
</Style>
</DataGrid.ItemContainerStyle>
<DataGrid.Columns >
<DataGridTextColumn Header="ID" Binding="{Binding Path=card_type_id}" Width="100" />
<DataGridTextColumn Header="Description" Binding="{Binding Path=card_type_desc}" Width="400" />
</DataGrid.Columns>
</DataGrid>
</Grid>
</TabItem>
</TabControl>
</Grid>