<ListView SelectionChanged="RecordSelected" Height="134" HorizontalAlignment="Left" Margin="10,10,0,0" Name="processList" VerticalAlignment="Top" Width="207">
<ListView.ItemTemplate>
<DataTemplate x:Name="record" DataType="{x:Type local:MyApp}">
<StackPanel Name="cell" Orientation="Vertical" KeyUp="cell_KeyUp">
<StackPanel KeyUp="cell_KeyUp" GotFocus="RecordSelected" KeyDown="RecordSelected" MouseDown="RecordSelected" Orientation="Horizontal" Tag="{Binding MyApp}">
<CheckBox BorderThickness="1" IsChecked="{Binding IsChecked}" Margin="3,3,3,3" Name="checkbox" />
<TextBlock GotFocus="RecordSelected" HorizontalAlignment="Left" KeyDown="RecordSelected" Margin="3,0,0,3" Name="displayname" Text="{Binding DisplayName}" VerticalAlignment="Center" Width="200" />
</StackPanel>
</StackPanel>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
我在datatemplate内的两个堆栈面板上都添加了一个KeyUp事件,但它不会触发。wpf listbox datatemplate中的键盘事件
它的工作。大。谢谢 – gangt