我试图让用户从我的数据库中选择要显示的表,我听说这样做的最佳方法是使用“selectedIndexChanged”事件,这样当用户单击所需的表时,它会立即显示它。但是,出于某种原因,当我单击我的组合框然后单击事件时,我没有看到“selectedIndexChanged”作为一个选项,并且在手动编写时显示:“无法识别成员“SelectedIndexChanged”或无法访问“这是我的 xaml 代码:
<Window x:Class="WpfApp1.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:WpfApp1"
mc:Ignorable="d"
Title="MainWindow" Height="350" Width="525">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="4*"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<Canvas Name="mycanvas" Background="LightBlue" Margin="0,0,34.4,-0.2">
<DataGrid Name="g1">
</DataGrid>
<Label Name="l1" Content="" FontWeight="ExtraBold" FontSize="15" Foreground="{x:Null}" Canvas.Left="20"/>
</Canvas>
<Canvas Grid.Column="1">
<Label Name="Instruction" Content="Choose a table" FontWeight="ExtraBold" FontSize="15" Canvas.Left="-23" Canvas.Top="62"/>
<ComboBox SelectedIndexChanged="b1" Name="ComboBox1" FontWeight="Bold" FontSize="15" Canvas.Top="98" Width="135" Height="24" Canvas.Left="-31">
<ComboBoxItem Foreground="#FF3FA4C5" Name="classesTbl">classesTbl</ComboBoxItem>
<ComboBoxItem Foreground="#FF3FA4C5" Name="gradesTbl">gradesTbl</ComboBoxItem>
<ComboBoxItem Foreground="#FF3FA4C5" Name="studentsTbl">studentsTbl</ComboBoxItem>
<ComboBoxItem Foreground="#FF3FA4C5" Name="subjectsTbl">subjectsTbl</ComboBoxItem>
<ComboBoxItem Foreground="#FF3FA4C5" Name="subjectsTeachers">subjectsTeachers</ComboBoxItem>
<ComboBoxItem Foreground="#FF3FA4C5" Name="TeachersTbl">TeachersTbl</ComboBoxItem>
</ComboBox>
</Canvas>
</Grid>
有谁知道如何解决它或我做错了什么?
蛊毒传说
白板的微信
相关分类