using System; using System.Collections.Generic; using System.Text; 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 SunlightAggregationManager.View { /// /// MachinePage.xaml 的交互逻辑 /// public partial class MachinePage : UserControl { public MachinePage() { InitializeComponent(); } private string id = ""; private void DataGridmachines_SelectionChanged(object sender, SelectionChangedEventArgs e) { int rownum = DataGridmachines.SelectedIndex;//获取鼠标选中行并定义变量 if (rownum != -1)//判断鼠标定位是否有效 { var row_ = DataGridmachines.Columns[0].GetCellContent(DataGridmachines.Items[rownum]); if (row_ is TextBlock textBlock) { id = textBlock.Text;//定位第0列, } } } } }