using System; #if netle40 using GalaSoft.MvvmLight.Command; #else using GalaSoft.MvvmLight.CommandWpf; #endif using HandyControlDemo.Data; using HandyControlDemo.Service; namespace HandyControlDemo.ViewModel { public class CardDemoViewModel : DemoViewModelBase { private readonly DataService _dataService; public CardDemoViewModel(DataService dataService) { _dataService = dataService; DataList = dataService.GetCardDataList(); } public RelayCommand AddItemCmd => new Lazy(() => new RelayCommand(() => DataList.Insert(0, _dataService.GetCardData()))).Value; public RelayCommand RemoveItemCmd => new Lazy(() => new RelayCommand(() => { if (DataList.Count > 0) { DataList.RemoveAt(0); } })).Value; } }