ItemViewModel.cs 756 B

1234567891011121314151617181920212223242526272829
  1. // Copyright (c) The Avalonia Project. All rights reserved.
  2. // Licensed under the MIT license. See licence.md file in the project root for full license information.
  3. using System;
  4. using ReactiveUI;
  5. namespace VirtualizationDemo.ViewModels
  6. {
  7. internal class ItemViewModel : ReactiveObject
  8. {
  9. private string _prefix;
  10. private int _index;
  11. private double _height = double.NaN;
  12. public ItemViewModel(int index, string prefix = "Item")
  13. {
  14. _prefix = prefix;
  15. _index = index;
  16. }
  17. public string Header => $"{_prefix} {_index}";
  18. public double Height
  19. {
  20. get => _height;
  21. set => this.RaiseAndSetIfChanged(ref _height, value);
  22. }
  23. }
  24. }