最近做一个工具,突然发现ListBox和ListView等列表控件的MouseDoubleClick事件有时候是获取不到当前双击的行对象数据的,比如这样写:
<ListBox Grid.Row="1" ItemsSource="{Binding DataList}" MouseDoubleClick="ListBox_MouseDoubleClick" SelectedItem="{Binding CurrentSelectItem}" Background="AliceBlue"> <ListBox.ItemTemplate> <DataTemplate> <DockPanel Height="50" Background="DarkGray" Width="300"> <TextBox Text="{Binding Name}" Height="30" Width="200" Background="DimGray"></TextBox> </DockPanel> </DataTemplate> </ListBox.ItemTemplate> </ListBox>