123456789101112131415161718192021222324252627282930 |
- using System.Collections.ObjectModel;
- using CommunityToolkit.Mvvm.ComponentModel;
- using CommunityToolkit.Mvvm.Input;
- namespace WpfSample.ViewModels {
- internal partial class MainViewModel: ObservableObject {
- public MainViewModel() {
- Random random = new Random();
- for (int i = random.Next(1, 10); i >= 0; --i) {
- Groups.Add(new DemoGroupViewModel() {
- Name = $"G{i}",
- });
- }
- }
- [ObservableProperty]
- private string message = string.Empty;
- public ObservableCollection<DemoGroupViewModel> Groups { get; set; } = new ObservableCollection<DemoGroupViewModel>();
- class Test {
- public string Name { get; set; } = string.Empty;
- }
- [RelayCommand]
- private void AddItem() {
- Groups[0].AddItemCommand?.Execute(null);
- }
- }
- }
|