Double-click the wpf DataGrid Control to obtain the current row.

Source: Internet
Author: User
Tags wpf datagrid

Double-click the wpf DataGrid Control to obtain the current row.

<DataGrid Margin = "10" HorizontalAlignment = "Left" verticalignment = "Top" AutoGenerateColumns = "False" ItemsSource = "{Binding}" Name = "dg_cards" MouseDoubleClick = "success"> <DataGrid. columns> <maid Header = "ID" Width = "40" Binding = "{Binding index}" IsReadOnly = "True"/> <maid Header = "enable" Width = "50 "> <maid. cellTemplate> <DataTemplate> <CheckBox Name = "cbStatus" MinWidth = "{Binding ID}" Uid = "{Binding Path = ID}" IsChecked = "{Binding IsChecked}" Tag = "{Binding ID}"/> </DataTemplate> </DataGridTemplateColumn. cellTemplate> </maid> <maid Header = "bayonet" Width = "80" IsReadOnly = "True" Binding = "{Binding cardname}"/> <maid Header = "eight ports card "Width =" 80 "> <DataGridTemplateColumn. cellTemplate> <DataTemplate> <CheckBox Name = "cbeight" IsChecked = "{Binding IsEChecked}"/> </DataTemplate> </DataGridTemplateColumn. cellTemplate> </DataGridTemplateColumn> <DataGridTextColumn Header = "operation" Width = "80" IsReadOnly = "True" Binding = "{Binding op}"/> </DataGrid. columns> </DataGrid>

 

Background code:

Private void dg_cards_MouseDoubleClick (object sender, MouseButtonEventArgs e) {bool isEight = false; DataGrid dg = sender as DataGrid; // double-click to obtain the control of the third column DataGridTemplateColumn templeColumn1 = dg. columns [3] as maid; FrameworkElement fwElement1 = dg_cards.Columns [3]. getCellContent (dg. currentItem); CheckBox cBox1 = templeColumn1.CellTemplate. findName ("cbeight", fwElement1) as CheckBox; if (bool) cBox1.IsChecked) {isEight = true ;}}

  

Related Article

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.