Double-click event Issues for WPF ListView and ListBox

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.