The last two articles say that double-clicking a row does not get the current data object problem,
Http://www.cnblogs.com/ligl/p/5636899.html
Http://www.cnblogs.com/ligl/p/5629802.html
Later, it was found that the MouseButtonEventArgs parameter can be obtained from the
<listbox grid.row="1"Itemssource="{Binding DataList}"MouseDoubleClick="Listbox_mousedoubleclick"SelectedItem="{Binding Currentselectitem}"Background="AliceBlue"> <ListBox.ItemTemplate> <DataTemplate> <dockpanel height=" -"Background="Darkgray"Width=" -"> <textbox text="{Binding Name}"height=" -"Width=" $"Background="Dimgray"></TextBox> </DockPanel> </DataTemplate> </listbox.it Emtemplate> </ListBox>
View Code
Private voidListbox_mousedoubleclick (Objectsender, MouseButtonEventArgs e) { varTxtbox = E.device.target asTextBox; varModel=txtbox.datacontext asListboxmodel; ListBox ListBox= Sender asListBox; if(ListBox = =NULL|| Listbox.selecteditem = =NULL) {MessageBox.Show ("ListBox1 Double-click the object to be empty ..."); } }
View Code
The main code is as follows
private void Listbox_mousedoubleclick (object sender, MouseButtonEventArgs e) {
var as var as Listboxmodel;//listboxmodel is a custom data object
}
Double-click event Issues for WPF ListView and ListBox