using GalaSoft.MvvmLight; using GalaSoft.MvvmLight.Command; using Microsoft.Extensions.DependencyInjection; using SlnMesnac.Business.business; using SlnMesnac.Config; using SlnMesnac.Model.domain; using System; using System.Collections.Generic; using System.Collections.ObjectModel; using System.Linq; using System.Text; using System.Threading.Tasks; namespace SlnMesnac.WPF.ViewModel { internal class IndexControlViewModel : ViewModelBase { private InStoreBusiness inStoreBusiness; public IndexControlViewModel() { this.inStoreBusiness = App.ServiceProvider.GetService(); UpdateInStoreFlagCommand = new RelayCommand(obj => { Console.WriteLine($"{obj};设置"); }); this.Init(); InStoreAmount = inStoreAmount + "19"; } #region 参数定义 public string inStoreAmount = "入库数量:"; public string InStoreAmount { get { return this.inStoreAmount; } set { inStoreAmount = value; RaisePropertyChanged(nameof(InStoreAmount)); } } /// /// A区域货道集合 /// public ObservableCollection _areaA_SpaceInfo; public ObservableCollection AreaA_SpaceInfo { get { return _areaA_SpaceInfo; } set { _areaA_SpaceInfo = value; RaisePropertyChanged(nameof(AreaA_SpaceInfo)); } } /// /// B区域货道集合 /// public ObservableCollection _areaB_SpaceInfo; public ObservableCollection AreaB_SpaceInfo { get { return _areaB_SpaceInfo; } set { _areaB_SpaceInfo = value; RaisePropertyChanged(nameof(AreaB_SpaceInfo)); } } #endregion public RelayCommand UpdateInStoreFlagCommand { get; set; } private ObservableCollection spaceItems = new ObservableCollection(); private void Init() { App.Current.Dispatcher.BeginInvoke((Action)(() => { var info = inStoreBusiness.GetBaseSpaceinfos("A"); if (info != null) { if (spaceItems.Count > 0) { spaceItems.Clear(); } info = info.OrderByDescending(x=>x.SpaceName).ToList(); foreach (var item in info) { spaceItems.Add(item); } AreaA_SpaceInfo = spaceItems; } })); App.Current.Dispatcher.BeginInvoke((Action)(() => { var info = inStoreBusiness.GetBaseSpaceinfos("A"); if (info != null) { if (spaceItems.Count > 0) { spaceItems.Clear(); } info = info.OrderByDescending(x => x.SpaceName).ToList(); foreach (var item in info) { spaceItems.Add(item); } AreaB_SpaceInfo = spaceItems; } })); } } }