ExceptionErrorViewModel.cs 612 B

1234567891011121314151617181920212223242526
  1. using ReactiveUI;
  2. using System;
  3. namespace BindingDemo.ViewModels
  4. {
  5. public class ExceptionErrorViewModel : ReactiveObject
  6. {
  7. private int _lessThan10;
  8. public int LessThan10
  9. {
  10. get { return _lessThan10; }
  11. set
  12. {
  13. if (value < 10)
  14. {
  15. this.RaiseAndSetIfChanged(ref _lessThan10, value);
  16. }
  17. else
  18. {
  19. throw new ArgumentOutOfRangeException(nameof(value), "Value must be less than 10.");
  20. }
  21. }
  22. }
  23. }
  24. }