WPF 获取ListView中列添加LinkButton按钮,点击按钮的当前行的ID值

前台

     把ID值绑定到Tag属性中    (Tag="{Binding Path=id}")
       
           
               
                   
                       
                       
                            
                               
                                   

                                       
                                           
                                               
                                                     
                                                       
                                                   

                                               

                                           

                                           
                                               
                                           

                                       

                                       
                                           
                                               
                                                     
                                               
                                                   

                                               

                                           

                                           
                                               
                                           

                                       

                                    
                               
                           
                       
                       
                   
               
           
       

 

 

后台读取Tag 中的ID值

 ///


        /// 删除当前行
        ///

        ///
        ///
        private void btnDelete_Click(object sender, RoutedEventArgs e)
        {
            int selectedIndex = int.Parse((sender as Button).Tag.ToString());
            DataRow dr = ((DataRowView)this.lvSelfDefine.Items[selectedIndex]).Row;
            string nodeID = dr["id"].ToString();
        }

 

你可能感兴趣的:(WPF 获取ListView中列添加LinkButton按钮,点击按钮的当前行的ID值)