OptionDialogViewModel.cs 730 B

1234567891011121314151617181920212223242526
  1. using Avalonia.Layout;
  2. using CommunityToolkit.Mvvm.ComponentModel;
  3. using CommunityToolkit.Mvvm.Input;
  4. using System.Collections.ObjectModel;
  5. namespace InABox.Avalonia.Dialogs;
  6. public partial class OptionDialogViewModel : BasePopupViewModel<string>, IAlignedPopup
  7. {
  8. [ObservableProperty]
  9. private string _title = "Select Option";
  10. [ObservableProperty]
  11. private ObservableCollection<string> _options = new();
  12. public HorizontalAlignment HorizontalAlignment => HorizontalAlignment.Stretch;
  13. public VerticalAlignment VerticalAlignment => VerticalAlignment.Center;
  14. [RelayCommand]
  15. private void Cancel() => Close(null);
  16. [RelayCommand]
  17. private void Select(string option) => Close(option);
  18. }