1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33
| public class Form1ViewModel: ViewModelBase { private int _count;
public ICommand ChangeCountCommand { get; set; }
public Form1ViewModel() { CanChangeCount = _ => true; ChangeCount = (count) => Count++; ChangeCountCommand = new RelayCommand(CanChangeCount,ChangeCount); }
public Func<object,bool> CanChangeCount { get; set; }
public Action<object> ChangeCount { get; set; }
public int Name { get { return _count; } set { if(value != _count) { _count = value; Notify(); } } } }
|