Files
HandyControl/src/Shared/HandyControlDemo_Shared/ViewModel/Controls/CardDemoViewModel.cs
T
2019-08-10 21:24:37 +08:00

35 lines
946 B
C#

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<CardModel>
{
private readonly DataService _dataService;
public CardDemoViewModel(DataService dataService)
{
_dataService = dataService;
DataList = dataService.GetCardDataList();
}
public RelayCommand AddItemCmd => new Lazy<RelayCommand>(() =>
new RelayCommand(() => DataList.Insert(0, _dataService.GetCardData()))).Value;
public RelayCommand RemoveItemCmd => new Lazy<RelayCommand>(() =>
new RelayCommand(() =>
{
if (DataList.Count > 0)
{
DataList.RemoveAt(0);
}
})).Value;
}
}