using Aucma.Core.Palletiz.Models; using CommunityToolkit.Mvvm.ComponentModel; using CommunityToolkit.Mvvm.Input; using System; using System.Collections.Generic; using System.Collections.ObjectModel; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows; namespace Aucma.Core.Palletiz.ViewModels { public partial class StatisticsPageViewModel : ObservableObject { public StatisticsPageViewModel() { LoadData(); } List materialComplateInfos = new List(); #region 加载DataGrid数据 private void LoadData() { //MaterialDataGrid.Add(new MaterialComplateInfo() { No = 1, ProductPlanCode = "8659452123",MaterialCode = "8659452123", MaterialName = "SC-AUCMA-农夫山泉,SC", PlanAmount = 50, CompleteAmount = 10 }); } #endregion #region 初始化datagrid private ObservableCollection materialDataGrid = new ObservableCollection(); public ObservableCollection MaterialDataGrid { get { return materialDataGrid; } set { materialDataGrid = value; OnPropertyChanged();//属性通知 } } #endregion #region 查询 /// /// 查询 /// [RelayCommand] private void ExecQuery(object obj) { string result =(string)obj; System.Windows.Application.Current.Dispatcher.Invoke((Action)(() => { if (!string.IsNullOrEmpty(result)) { MaterialDataGrid.Clear(); //foreach (MaterialComplateInfo info in materialDataGrid) //{ // MaterialDataGrid.Add(info); //} } else { MaterialDataGrid.Clear(); LoadData(); } //Datalist.Insert(0, Datalist[Datalist.Count - 1]); //Datalist.RemoveAt(Datalist.Count - 1); })); } #endregion } }