95 lines
2.8 KiB
C#
95 lines
2.8 KiB
C#
using Ping9719.WpfEx;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
using System.Web.UI.WebControls;
|
|
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.Shapes;
|
|
using 货架标准上位机.ViewModel;
|
|
|
|
namespace 货架标准上位机
|
|
{
|
|
public partial class MatInfoView : UserControlBase
|
|
{
|
|
public MatInfoViewModel viewModel { get; set; } = new MatInfoViewModel();
|
|
public MatInfoView()
|
|
{
|
|
InitializeComponent();
|
|
this.DataContext = viewModel;
|
|
}
|
|
|
|
private void LoadedVisible(object sender, EventArgs e)
|
|
{
|
|
viewModel.BtnReset();
|
|
viewModel.BtnSearchReset();
|
|
}
|
|
|
|
private void DataGrid_SelectionChanged(object sender, SelectionChangedEventArgs e)
|
|
{
|
|
try
|
|
{
|
|
if (viewModel.SelectedataGridItem != null)
|
|
{
|
|
viewModel.SelectedataGridItem.IsSelected = !viewModel.SelectedataGridItem.IsSelected;
|
|
//dataGrid.UnselectAllCells();
|
|
}
|
|
|
|
}
|
|
catch
|
|
{
|
|
|
|
}
|
|
}
|
|
|
|
private void DataGrid_SelectedCellsChanged(object sender, SelectedCellsChangedEventArgs e)
|
|
{
|
|
|
|
}
|
|
|
|
private void allChecked_Checked(object sender, RoutedEventArgs e)
|
|
{
|
|
if (viewModel != null && viewModel.DataGridItemSource != null && viewModel.DataGridItemSource.Count() > 0)
|
|
{
|
|
foreach (var item in viewModel.DataGridItemSource)
|
|
{
|
|
item.IsSelected = true;
|
|
}
|
|
}
|
|
}
|
|
|
|
private void allChecked_Unchecked(object sender, RoutedEventArgs e)
|
|
{
|
|
if (viewModel != null && viewModel.DataGridItemSource != null && viewModel.DataGridItemSource.Count() > 0)
|
|
{
|
|
foreach (var item in viewModel.DataGridItemSource)
|
|
{
|
|
item.IsSelected = false;
|
|
}
|
|
}
|
|
}
|
|
|
|
private void DataGrid_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
|
|
{
|
|
// 获取点击的 DataGridRow
|
|
var hitTestInfo = VisualTreeHelper.HitTest(dataGrid, e.GetPosition(dataGrid));
|
|
if (hitTestInfo.VisualHit is DataGridRow row)
|
|
{
|
|
// 现在你可以根据 row 做一些事情,比如选中它(如果它还没有被选中)
|
|
if (!row.IsSelected)
|
|
{
|
|
row.IsSelected = true;
|
|
}
|
|
|
|
}
|
|
}
|
|
}
|
|
}
|