using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows; using System.Windows.Controls; using System.Windows.Data; using System.Windows.Documents; using System.Windows.Input; using System.Windows.Media; using System.Windows.Media.Imaging; using System.Windows.Navigation; using System.Windows.Shapes; namespace Audit.View { /// /// StuffView.xaml 的交互逻辑 /// public partial class StuffView : UserControl { /// /// StuffView /// public StuffView() { InitializeComponent(); } private void Button_Preservation(object sender, RoutedEventArgs e) { } private void Button_Delete(object sender, RoutedEventArgs e) { } private void DataGridStuff_MouseDoubleClick(object sender, MouseButtonEventArgs e) { int rownum = this.DataGridStuff.SelectedIndex;//获取鼠标选中行并定义变量 string DataGridStuff_ProductCode = (DataGridStuff.Columns[1].GetCellContent(DataGridStuff.Items[rownum]) as TextBlock).Text;//定位第0列选中行单元格, string DataGridStuff_ProductName = (DataGridStuff.Columns[2].GetCellContent(DataGridStuff.Items[rownum]) as TextBlock).Text;//定位第0列选中行单元格, string DataGridStuff_Price = (DataGridStuff.Columns[3].GetCellContent(DataGridStuff.Items[rownum]) as TextBlock).Text;//定位第0列选中行单元格, string DataGridStuff_ProductUnit = (DataGridStuff.Columns[4].GetCellContent(DataGridStuff.Items[rownum]) as TextBlock).Text;//定位第0列选中行单元格, string DataGridStuff_ProductType = (DataGridStuff.Columns[5].GetCellContent(DataGridStuff.Items[rownum]) as TextBlock).Text;//定位第0列选中行单元格, string DataGridStuff_Color = (DataGridStuff.Columns[6].GetCellContent(DataGridStuff.Items[rownum]) as TextBlock).Text;//定位第0列选中行单元格, string DataGridStuff_Concentration = (DataGridStuff.Columns[7].GetCellContent(DataGridStuff.Items[rownum]) as TextBlock).Text;//定位第0列选中行单元格, string DataGridStuff_GRAVITY = (DataGridStuff.Columns[8].GetCellContent(DataGridStuff.Items[rownum]) as TextBlock).Text;//定位第0列选中行单元格, stuff_ProductCode.Text = DataGridStuff_ProductCode.ToString(); stuff_ProductName.Text = DataGridStuff_ProductName.ToString(); stuff_Price.Text = DataGridStuff_Price.ToString(); stuff_ProductUnit.Text = DataGridStuff_ProductUnit.ToString(); stuff_ProductType.Text= DataGridStuff_ProductType.ToString(); stuff_Color.Text = DataGridStuff_Color.ToString(); stuff_Concentration.Text = DataGridStuff_Concentration.ToString(); stuff_GRAVITY.Text = DataGridStuff_GRAVITY.ToString(); } } }