Files
HandyControl/src/Shared/HandyControlDemo_Shared/ViewModel/Controls/CardDemoViewModel.cs
T

27 lines
654 B
C#

using GalaSoft.MvvmLight.Command;
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(() => DataList.Insert(0, _dataService.GetCardData()));
public RelayCommand RemoveItemCmd => new(() =>
{
if (DataList.Count > 0)
{
DataList.RemoveAt(0);
}
});
}