[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M6DYNJPJAB22JJK3CX69MDNB":3,"skill-same:01M6DYNJPJAB22JJK3CX69MDNB":95},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":16,"categories":17,"keywords":23,"publishedAt":47,"linkOnly":48,"markdownContent":49,"markdownBody":50,"frontMatter":51,"refName":53,"commitSha":54,"skillDirectory":55,"forksCount":56,"repositoryHtmlUrl":57,"repositoryHomepageUrl":58,"ownerHtmlUrl":59,"ownerBlogUrl":60,"ownerDescription":61,"updatedAt":62,"install":63,"resources":76},"01M6DYNJPJAB22JJK3CX69MDNB","mvvm",null,"Implement the Model-View-ViewModel pattern in .NET applications with proper separation of concerns, data binding, commands, and testable ViewModels using MVVM Toolkit. USE FOR: implementing UI separation with Model-View-ViewModel; using MVVM Toolkit (CommunityToolkit.Mvvm) for ViewModels; designing testable UI architecture. DO NOT USE FOR: unrelated stacks; generic tasks that do not need this specific guidance. INVOKES: inspect the repository context, edit targeted files, and run relevant build, test, lint, or validation commands when changes are made.","managedcode\u002Fdotnet-skills","managedcode","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F78253589?v=4","01M6DYDJR3EG8KB5G4PC65XCTT","Managed Code","01M6DYDJX0ZT432N04NYJW89DN",515,"MIT","https:\u002F\u002Fgithub.com\u002Fmanagedcode\u002Fdotnet-skills\u002Fblob\u002Fmain\u002Fcatalog\u002FLibraries\u002FMVVM-Toolkit\u002Fskills\u002Fmvvm\u002FSKILL.md",[18],{"categoryNo":19,"categoryName":20,"taxonomyType":21,"taxonomyTypeDesc":22},"01JBSEEDCAT000000000000008","测试与质量","SCENARIO","使用场景",[5,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46],"when","architecture","implementing","inspect","relevant","uno platform","separation of concerns","commands","pattern","do","files","unrelated","context","edit","model","projects","mvvm toolkit","data","repository","ui","blazor","run","tasks","2026-11-10 10:12:30",false,"---\nname: mvvm\ndescription: \"Implement the Model-View-ViewModel pattern in .NET applications with proper separation of concerns, data binding, commands, and testable ViewModels using MVVM Toolkit. USE FOR: implementing UI separation with Model-View-ViewModel; using MVVM Toolkit (CommunityToolkit.Mvvm) for ViewModels; designing testable UI architecture. DO NOT USE FOR: unrelated stacks; generic tasks that do not need this specific guidance. INVOKES: inspect the repository context, edit targeted files, and run relevant build, test, lint, or validation commands when changes are made.\"\ncompatibility: \"Applies to WPF, MAUI, WinUI, Uno Platform, Avalonia, and Blazor projects.\"\n---\n\n# MVVM Pattern for .NET\n\n## Trigger On\n\n- implementing UI separation with Model-View-ViewModel\n- using MVVM Toolkit (CommunityToolkit.Mvvm) for ViewModels\n- designing testable UI architecture\n- handling commands, property changes, and messaging\n- choosing between MVVM frameworks\n\n## Documentation\n\n- [MVVM Toolkit Overview](https:\u002F\u002Flearn.microsoft.com\u002Fen-us\u002Fdotnet\u002Fcommunitytoolkit\u002Fmvvm\u002F)\n- [ObservableObject](https:\u002F\u002Flearn.microsoft.com\u002Fen-us\u002Fdotnet\u002Fcommunitytoolkit\u002Fmvvm\u002Fobservableobject)\n- [RelayCommand](https:\u002F\u002Flearn.microsoft.com\u002Fen-us\u002Fdotnet\u002Fcommunitytoolkit\u002Fmvvm\u002Frelaycommand)\n- [Messenger](https:\u002F\u002Flearn.microsoft.com\u002Fen-us\u002Fdotnet\u002Fcommunitytoolkit\u002Fmvvm\u002Fmessenger)\n- [Source Generators](https:\u002F\u002Flearn.microsoft.com\u002Fen-us\u002Fdotnet\u002Fcommunitytoolkit\u002Fmvvm\u002Fgenerators\u002Foverview)\n\n## References\n\nSee detailed examples in the `references\u002F` folder:\n- [`patterns.md`](references\u002Fpatterns.md) — ViewModel, command, navigation, and state patterns\n- [`anti-patterns.md`](references\u002Fanti-patterns.md) — Common mistakes and how to fix them\n\n## Core Concepts\n\n| Component | Responsibility | Example |\n|-----------|---------------|---------|\n| **Model** | Business logic and data | `Product`, `Order`, `User` |\n| **View** | UI presentation (XAML\u002FRazor) | `ProductPage.xaml` |\n| **ViewModel** | UI logic and state | `ProductViewModel` |\n\n## Workflow\n\n1. **Keep Views dumb** — no business logic in code-behind\n2. **Use data binding** — connect View to ViewModel properties\n3. **Commands for actions** — handle user interactions via ICommand\n4. **Inject dependencies** — services go into ViewModel constructors\n5. **Test ViewModels** — they should be unit testable without UI\n\n## MVVM Toolkit Setup\n\n```xml\n\u003CPackageReference Include=\"CommunityToolkit.Mvvm\" Version=\"8.*\" \u002F>\n```\n\n## ViewModel Patterns\n\n### Basic ViewModel with Source Generators\n```csharp\npublic partial class ProductViewModel(IProductService productService) : ObservableObject\n{\n    [ObservableProperty]\n    private string _name = string.Empty;\n\n    [ObservableProperty]\n    private decimal _price;\n\n    [ObservableProperty]\n    [NotifyCanExecuteChangedFor(nameof(SaveCommand))]\n    private bool _isValid;\n\n    [RelayCommand(CanExecute = nameof(CanSave))]\n    private async Task SaveAsync()\n    {\n        await productService.SaveAsync(new Product { Name = Name, Price = Price });\n    }\n\n    private bool CanSave() => IsValid && !string.IsNullOrEmpty(Name);\n}\n```\n\n### Property Changed Notifications\n```csharp\npublic partial class OrderViewModel : ObservableObject\n{\n    [ObservableProperty]\n    private int _quantity;\n\n    [ObservableProperty]\n    private decimal _unitPrice;\n\n    \u002F\u002F Computed property - manually notify\n    public decimal Total => Quantity * UnitPrice;\n\n    partial void OnQuantityChanged(int value)\n    {\n        OnPropertyChanged(nameof(Total));\n    }\n\n    partial void OnUnitPriceChanged(decimal value)\n    {\n        OnPropertyChanged(nameof(Total));\n    }\n}\n```\n\n### Collection ViewModel\n```csharp\npublic partial class ProductListViewModel(IProductService productService) : ObservableObject\n{\n    [ObservableProperty]\n    private ObservableCollection\u003CProductViewModel> _products = [];\n\n    [ObservableProperty]\n    private ProductViewModel? _selectedProduct;\n\n    [ObservableProperty]\n    private bool _isLoading;\n\n    [RelayCommand]\n    private async Task LoadProductsAsync()\n    {\n        IsLoading = true;\n        try\n        {\n            var items = await productService.GetAllAsync();\n            Products = new ObservableCollection\u003CProductViewModel>(\n                items.Select(p => new ProductViewModel(productService)\n                {\n                    Name = p.Name,\n                    Price = p.Price\n                }));\n        }\n        finally\n        {\n            IsLoading = false;\n        }\n    }\n\n    [RelayCommand]\n    private void DeleteProduct(ProductViewModel product)\n    {\n        Products.Remove(product);\n    }\n}\n```\n\n## Commands\n\n### Async Commands with Cancellation\n```csharp\npublic partial class SearchViewModel : ObservableObject\n{\n    [ObservableProperty]\n    private string _searchText = string.Empty;\n\n    [RelayCommand(IncludeCancelCommand = true)]\n    private async Task SearchAsync(CancellationToken token)\n    {\n        await Task.Delay(500, token); \u002F\u002F Debounce\n        \u002F\u002F Search logic with cancellation support\n    }\n}\n```\n\n### Command with Parameter\n```csharp\npublic partial class NavigationViewModel : ObservableObject\n{\n    [RelayCommand]\n    private void NavigateTo(string page)\n    {\n        \u002F\u002F Navigate to page\n    }\n\n    [RelayCommand]\n    private async Task OpenItemAsync(int itemId)\n    {\n        \u002F\u002F Load and open item\n    }\n}\n```\n\n## Messenger Pattern\n\n### Sending Messages\n```csharp\n\u002F\u002F Define message\npublic record ProductSelectedMessage(Product Product);\n\n\u002F\u002F Send from one ViewModel\nWeakReferenceMessenger.Default.Send(new ProductSelectedMessage(selectedProduct));\n```\n\n### Receiving Messages\n```csharp\npublic partial class ProductDetailViewModel : ObservableRecipient\n{\n    public ProductDetailViewModel()\n    {\n        IsActive = true; \u002F\u002F Enable message reception\n    }\n\n    protected override void OnActivated()\n    {\n        Messenger.Register\u003CProductDetailViewModel, ProductSelectedMessage>(\n            this, (r, m) => r.LoadProduct(m.Product));\n    }\n\n    private void LoadProduct(Product product)\n    {\n        \u002F\u002F Update UI with product details\n    }\n}\n```\n\n## Validation\n\n### Using ObservableValidator\n```csharp\npublic partial class RegistrationViewModel : ObservableValidator\n{\n    [ObservableProperty]\n    [NotifyDataErrorInfo]\n    [Required(ErrorMessage = \"Email is required\")]\n    [EmailAddress(ErrorMessage = \"Invalid email format\")]\n    private string _email = string.Empty;\n\n    [ObservableProperty]\n    [NotifyDataErrorInfo]\n    [Required]\n    [MinLength(8, ErrorMessage = \"Password must be at least 8 characters\")]\n    private string _password = string.Empty;\n\n    [RelayCommand(CanExecute = nameof(CanRegister))]\n    private async Task RegisterAsync()\n    {\n        ValidateAllProperties();\n        if (HasErrors) return;\n\n        \u002F\u002F Registration logic\n    }\n\n    private bool CanRegister() => !HasErrors;\n}\n```\n\n## Dependency Injection\n\n### Registration\n```csharp\n\u002F\u002F Services\nservices.AddSingleton\u003CIProductService, ProductService>();\nservices.AddSingleton\u003CINavigationService, NavigationService>();\n\n\u002F\u002F ViewModels\nservices.AddTransient\u003CProductListViewModel>();\nservices.AddTransient\u003CProductDetailViewModel>();\n\n\u002F\u002F Views (for View-first navigation)\nservices.AddTransient\u003CProductListPage>();\nservices.AddTransient\u003CProductDetailPage>();\n```\n\n### ViewModel Locator Pattern\n```csharp\npublic class ViewModelLocator\n{\n    private static IServiceProvider _provider = null!;\n\n    public static void Initialize(IServiceProvider provider) => _provider = provider;\n\n    public ProductListViewModel ProductList => _provider.GetRequiredService\u003CProductListViewModel>();\n    public ProductDetailViewModel ProductDetail => _provider.GetRequiredService\u003CProductDetailViewModel>();\n}\n```\n\n## View Binding\n\n### XAML Binding\n```xml\n\u003CPage x:Class=\"MyApp.Views.ProductListPage\"\n      xmlns:vm=\"using:MyApp.ViewModels\"\n      x:DataType=\"vm:ProductListViewModel\">\n\n    \u003CGrid>\n        \u003CProgressRing IsActive=\"{x:Bind ViewModel.IsLoading, Mode=OneWay}\"\n                      Visibility=\"{x:Bind ViewModel.IsLoading, Mode=OneWay}\" \u002F>\n\n        \u003CListView ItemsSource=\"{x:Bind ViewModel.Products, Mode=OneWay}\"\n                  SelectedItem=\"{x:Bind ViewModel.SelectedProduct, Mode=TwoWay}\">\n            \u003CListView.ItemTemplate>\n                \u003CDataTemplate x:DataType=\"vm:ProductViewModel\">\n                    \u003CStackPanel>\n                        \u003CTextBlock Text=\"{x:Bind Name, Mode=OneWay}\" \u002F>\n                        \u003CTextBlock Text=\"{x:Bind Price, Mode=OneWay}\" \u002F>\n                    \u003C\u002FStackPanel>\n                \u003C\u002FDataTemplate>\n            \u003C\u002FListView.ItemTemplate>\n        \u003C\u002FListView>\n\n        \u003CButton Content=\"Load\"\n                Command=\"{x:Bind ViewModel.LoadProductsCommand}\" \u002F>\n    \u003C\u002FGrid>\n\u003C\u002FPage>\n```\n\n## Anti-Patterns to Avoid\n\n| Anti-Pattern | Why It's Bad | Better Approach |\n|--------------|--------------|-----------------|\n| Logic in code-behind | Not testable | Move to ViewModel |\n| ViewModel knows View | Tight coupling | Use interfaces\u002Fmessaging |\n| Manual INotifyPropertyChanged | Verbose, error-prone | Use source generators |\n| God ViewModel | Unmaintainable | Split responsibilities |\n| Direct service calls in View | Violates separation | Go through ViewModel |\n| Exposing Model directly | Leaks implementation | Create ViewModel properties |\n\n## Testing ViewModels\n\n```csharp\npublic class ProductViewModelTests\n{\n    [Fact]\n    public async Task LoadProducts_PopulatesCollection()\n    {\n        \u002F\u002F Arrange\n        var mockService = new Mock\u003CIProductService>();\n        mockService.Setup(s => s.GetAllAsync())\n            .ReturnsAsync([new Product { Name = \"Test\", Price = 10 }]);\n\n        var viewModel = new ProductListViewModel(mockService.Object);\n\n        \u002F\u002F Act\n        await viewModel.LoadProductsCommand.ExecuteAsync(null);\n\n        \u002F\u002F Assert\n        Assert.Single(viewModel.Products);\n        Assert.Equal(\"Test\", viewModel.Products[0].Name);\n    }\n\n    [Fact]\n    public void SaveCommand_CannotExecute_WhenInvalid()\n    {\n        var viewModel = new ProductViewModel(Mock.Of\u003CIProductService>())\n        {\n            Name = \"\",\n            IsValid = false\n        };\n\n        Assert.False(viewModel.SaveCommand.CanExecute(null));\n    }\n}\n```\n\n## Framework Comparison\n\n| Feature | MVVM Toolkit | Prism | MVVMLight |\n|---------|--------------|-------|-----------|\n| Source generators | Yes | No | No |\n| Maintenance | Active | Active | Deprecated |\n| DI built-in | No | Yes | No |\n| Navigation | No | Yes | No |\n| Weight | Light | Heavy | Light |\n\n## Deliver\n\n- ViewModels that are fully unit testable\n- Clean separation between UI and business logic\n- Proper use of commands and data binding\n- Messaging for loose coupling between components\n\n## Validate\n\n- No business logic in code-behind files\n- ViewModels don't reference View types\n- Commands are used for all user actions\n- Properties use ObservableProperty or equivalent\n- Dependencies are injected, not created\n- Unit tests cover ViewModel logic\n","# MVVM Pattern for .NET\n\n## Trigger On\n\n- implementing UI separation with Model-View-ViewModel\n- using MVVM Toolkit (CommunityToolkit.Mvvm) for ViewModels\n- designing testable UI architecture\n- handling commands, property changes, and messaging\n- choosing between MVVM frameworks\n\n## Documentation\n\n- [MVVM Toolkit Overview](https:\u002F\u002Flearn.microsoft.com\u002Fen-us\u002Fdotnet\u002Fcommunitytoolkit\u002Fmvvm\u002F)\n- [ObservableObject](https:\u002F\u002Flearn.microsoft.com\u002Fen-us\u002Fdotnet\u002Fcommunitytoolkit\u002Fmvvm\u002Fobservableobject)\n- [RelayCommand](https:\u002F\u002Flearn.microsoft.com\u002Fen-us\u002Fdotnet\u002Fcommunitytoolkit\u002Fmvvm\u002Frelaycommand)\n- [Messenger](https:\u002F\u002Flearn.microsoft.com\u002Fen-us\u002Fdotnet\u002Fcommunitytoolkit\u002Fmvvm\u002Fmessenger)\n- [Source Generators](https:\u002F\u002Flearn.microsoft.com\u002Fen-us\u002Fdotnet\u002Fcommunitytoolkit\u002Fmvvm\u002Fgenerators\u002Foverview)\n\n## References\n\nSee detailed examples in the `references\u002F` folder:\n- [`patterns.md`](references\u002Fpatterns.md) — ViewModel, command, navigation, and state patterns\n- [`anti-patterns.md`](references\u002Fanti-patterns.md) — Common mistakes and how to fix them\n\n## Core Concepts\n\n| Component | Responsibility | Example |\n|-----------|---------------|---------|\n| **Model** | Business logic and data | `Product`, `Order`, `User` |\n| **View** | UI presentation (XAML\u002FRazor) | `ProductPage.xaml` |\n| **ViewModel** | UI logic and state | `ProductViewModel` |\n\n## Workflow\n\n1. **Keep Views dumb** — no business logic in code-behind\n2. **Use data binding** — connect View to ViewModel properties\n3. **Commands for actions** — handle user interactions via ICommand\n4. **Inject dependencies** — services go into ViewModel constructors\n5. **Test ViewModels** — they should be unit testable without UI\n\n## MVVM Toolkit Setup\n\n```xml\n\u003CPackageReference Include=\"CommunityToolkit.Mvvm\" Version=\"8.*\" \u002F>\n```\n\n## ViewModel Patterns\n\n### Basic ViewModel with Source Generators\n```csharp\npublic partial class ProductViewModel(IProductService productService) : ObservableObject\n{\n    [ObservableProperty]\n    private string _name = string.Empty;\n\n    [ObservableProperty]\n    private decimal _price;\n\n    [ObservableProperty]\n    [NotifyCanExecuteChangedFor(nameof(SaveCommand))]\n    private bool _isValid;\n\n    [RelayCommand(CanExecute = nameof(CanSave))]\n    private async Task SaveAsync()\n    {\n        await productService.SaveAsync(new Product { Name = Name, Price = Price });\n    }\n\n    private bool CanSave() => IsValid && !string.IsNullOrEmpty(Name);\n}\n```\n\n### Property Changed Notifications\n```csharp\npublic partial class OrderViewModel : ObservableObject\n{\n    [ObservableProperty]\n    private int _quantity;\n\n    [ObservableProperty]\n    private decimal _unitPrice;\n\n    \u002F\u002F Computed property - manually notify\n    public decimal Total => Quantity * UnitPrice;\n\n    partial void OnQuantityChanged(int value)\n    {\n        OnPropertyChanged(nameof(Total));\n    }\n\n    partial void OnUnitPriceChanged(decimal value)\n    {\n        OnPropertyChanged(nameof(Total));\n    }\n}\n```\n\n### Collection ViewModel\n```csharp\npublic partial class ProductListViewModel(IProductService productService) : ObservableObject\n{\n    [ObservableProperty]\n    private ObservableCollection\u003CProductViewModel> _products = [];\n\n    [ObservableProperty]\n    private ProductViewModel? _selectedProduct;\n\n    [ObservableProperty]\n    private bool _isLoading;\n\n    [RelayCommand]\n    private async Task LoadProductsAsync()\n    {\n        IsLoading = true;\n        try\n        {\n            var items = await productService.GetAllAsync();\n            Products = new ObservableCollection\u003CProductViewModel>(\n                items.Select(p => new ProductViewModel(productService)\n                {\n                    Name = p.Name,\n                    Price = p.Price\n                }));\n        }\n        finally\n        {\n            IsLoading = false;\n        }\n    }\n\n    [RelayCommand]\n    private void DeleteProduct(ProductViewModel product)\n    {\n        Products.Remove(product);\n    }\n}\n```\n\n## Commands\n\n### Async Commands with Cancellation\n```csharp\npublic partial class SearchViewModel : ObservableObject\n{\n    [ObservableProperty]\n    private string _searchText = string.Empty;\n\n    [RelayCommand(IncludeCancelCommand = true)]\n    private async Task SearchAsync(CancellationToken token)\n    {\n        await Task.Delay(500, token); \u002F\u002F Debounce\n        \u002F\u002F Search logic with cancellation support\n    }\n}\n```\n\n### Command with Parameter\n```csharp\npublic partial class NavigationViewModel : ObservableObject\n{\n    [RelayCommand]\n    private void NavigateTo(string page)\n    {\n        \u002F\u002F Navigate to page\n    }\n\n    [RelayCommand]\n    private async Task OpenItemAsync(int itemId)\n    {\n        \u002F\u002F Load and open item\n    }\n}\n```\n\n## Messenger Pattern\n\n### Sending Messages\n```csharp\n\u002F\u002F Define message\npublic record ProductSelectedMessage(Product Product);\n\n\u002F\u002F Send from one ViewModel\nWeakReferenceMessenger.Default.Send(new ProductSelectedMessage(selectedProduct));\n```\n\n### Receiving Messages\n```csharp\npublic partial class ProductDetailViewModel : ObservableRecipient\n{\n    public ProductDetailViewModel()\n    {\n        IsActive = true; \u002F\u002F Enable message reception\n    }\n\n    protected override void OnActivated()\n    {\n        Messenger.Register\u003CProductDetailViewModel, ProductSelectedMessage>(\n            this, (r, m) => r.LoadProduct(m.Product));\n    }\n\n    private void LoadProduct(Product product)\n    {\n        \u002F\u002F Update UI with product details\n    }\n}\n```\n\n## Validation\n\n### Using ObservableValidator\n```csharp\npublic partial class RegistrationViewModel : ObservableValidator\n{\n    [ObservableProperty]\n    [NotifyDataErrorInfo]\n    [Required(ErrorMessage = \"Email is required\")]\n    [EmailAddress(ErrorMessage = \"Invalid email format\")]\n    private string _email = string.Empty;\n\n    [ObservableProperty]\n    [NotifyDataErrorInfo]\n    [Required]\n    [MinLength(8, ErrorMessage = \"Password must be at least 8 characters\")]\n    private string _password = string.Empty;\n\n    [RelayCommand(CanExecute = nameof(CanRegister))]\n    private async Task RegisterAsync()\n    {\n        ValidateAllProperties();\n        if (HasErrors) return;\n\n        \u002F\u002F Registration logic\n    }\n\n    private bool CanRegister() => !HasErrors;\n}\n```\n\n## Dependency Injection\n\n### Registration\n```csharp\n\u002F\u002F Services\nservices.AddSingleton\u003CIProductService, ProductService>();\nservices.AddSingleton\u003CINavigationService, NavigationService>();\n\n\u002F\u002F ViewModels\nservices.AddTransient\u003CProductListViewModel>();\nservices.AddTransient\u003CProductDetailViewModel>();\n\n\u002F\u002F Views (for View-first navigation)\nservices.AddTransient\u003CProductListPage>();\nservices.AddTransient\u003CProductDetailPage>();\n```\n\n### ViewModel Locator Pattern\n```csharp\npublic class ViewModelLocator\n{\n    private static IServiceProvider _provider = null!;\n\n    public static void Initialize(IServiceProvider provider) => _provider = provider;\n\n    public ProductListViewModel ProductList => _provider.GetRequiredService\u003CProductListViewModel>();\n    public ProductDetailViewModel ProductDetail => _provider.GetRequiredService\u003CProductDetailViewModel>();\n}\n```\n\n## View Binding\n\n### XAML Binding\n```xml\n\u003CPage x:Class=\"MyApp.Views.ProductListPage\"\n      xmlns:vm=\"using:MyApp.ViewModels\"\n      x:DataType=\"vm:ProductListViewModel\">\n\n    \u003CGrid>\n        \u003CProgressRing IsActive=\"{x:Bind ViewModel.IsLoading, Mode=OneWay}\"\n                      Visibility=\"{x:Bind ViewModel.IsLoading, Mode=OneWay}\" \u002F>\n\n        \u003CListView ItemsSource=\"{x:Bind ViewModel.Products, Mode=OneWay}\"\n                  SelectedItem=\"{x:Bind ViewModel.SelectedProduct, Mode=TwoWay}\">\n            \u003CListView.ItemTemplate>\n                \u003CDataTemplate x:DataType=\"vm:ProductViewModel\">\n                    \u003CStackPanel>\n                        \u003CTextBlock Text=\"{x:Bind Name, Mode=OneWay}\" \u002F>\n                        \u003CTextBlock Text=\"{x:Bind Price, Mode=OneWay}\" \u002F>\n                    \u003C\u002FStackPanel>\n                \u003C\u002FDataTemplate>\n            \u003C\u002FListView.ItemTemplate>\n        \u003C\u002FListView>\n\n        \u003CButton Content=\"Load\"\n                Command=\"{x:Bind ViewModel.LoadProductsCommand}\" \u002F>\n    \u003C\u002FGrid>\n\u003C\u002FPage>\n```\n\n## Anti-Patterns to Avoid\n\n| Anti-Pattern | Why It's Bad | Better Approach |\n|--------------|--------------|-----------------|\n| Logic in code-behind | Not testable | Move to ViewModel |\n| ViewModel knows View | Tight coupling | Use interfaces\u002Fmessaging |\n| Manual INotifyPropertyChanged | Verbose, error-prone | Use source generators |\n| God ViewModel | Unmaintainable | Split responsibilities |\n| Direct service calls in View | Violates separation | Go through ViewModel |\n| Exposing Model directly | Leaks implementation | Create ViewModel properties |\n\n## Testing ViewModels\n\n```csharp\npublic class ProductViewModelTests\n{\n    [Fact]\n    public async Task LoadProducts_PopulatesCollection()\n    {\n        \u002F\u002F Arrange\n        var mockService = new Mock\u003CIProductService>();\n        mockService.Setup(s => s.GetAllAsync())\n            .ReturnsAsync([new Product { Name = \"Test\", Price = 10 }]);\n\n        var viewModel = new ProductListViewModel(mockService.Object);\n\n        \u002F\u002F Act\n        await viewModel.LoadProductsCommand.ExecuteAsync(null);\n\n        \u002F\u002F Assert\n        Assert.Single(viewModel.Products);\n        Assert.Equal(\"Test\", viewModel.Products[0].Name);\n    }\n\n    [Fact]\n    public void SaveCommand_CannotExecute_WhenInvalid()\n    {\n        var viewModel = new ProductViewModel(Mock.Of\u003CIProductService>())\n        {\n            Name = \"\",\n            IsValid = false\n        };\n\n        Assert.False(viewModel.SaveCommand.CanExecute(null));\n    }\n}\n```\n\n## Framework Comparison\n\n| Feature | MVVM Toolkit | Prism | MVVMLight |\n|---------|--------------|-------|-----------|\n| Source generators | Yes | No | No |\n| Maintenance | Active | Active | Deprecated |\n| DI built-in | No | Yes | No |\n| Navigation | No | Yes | No |\n| Weight | Light | Heavy | Light |\n\n## Deliver\n\n- ViewModels that are fully unit testable\n- Clean separation between UI and business logic\n- Proper use of commands and data binding\n- Messaging for loose coupling between components\n\n## Validate\n\n- No business logic in code-behind files\n- ViewModels don't reference View types\n- Commands are used for all user actions\n- Properties use ObservableProperty or equivalent\n- Dependencies are injected, not created\n- Unit tests cover ViewModel logic\n",{"name":5,"description":7,"compatibility":52},"Applies to WPF, MAUI, WinUI, Uno Platform, Avalonia, and Blazor projects.","main","497cc9aba79a931ac6fb8d36a48cc22fe3d6d74b","catalog\u002FLibraries\u002FMVVM-Toolkit\u002Fskills\u002Fmvvm",41,"https:\u002F\u002Fgithub.com\u002Fmanagedcode\u002Fdotnet-skills","https:\u002F\u002Fskills.managed-code.com","https:\u002F\u002Fgithub.com\u002Fmanagedcode","https:\u002F\u002Fwww.managed-code.com","Open Source Community for .NET Developers: Reliable, Actively Maintained, and Community-Driven. Made in Ukraine 🇺🇦 with ❤️","2026-11-14 19:05:44",{"source":8,"skillName":5,"commands":64,"prompt":74,"zipAvailable":75},[65,68,71],{"tool":66,"command":67},"npx","npx skills add managedcode\u002Fdotnet-skills --skill mvvm",{"tool":69,"command":70},"bunx","bunx skills add managedcode\u002Fdotnet-skills --skill mvvm",{"tool":72,"command":73},"pnpm","pnpm dlx skills add managedcode\u002Fdotnet-skills --skill mvvm","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002Fmanagedcode\u002Fdotnet-skills\u002Fblob\u002Fmain\u002Fcatalog\u002FLibraries\u002FMVVM-Toolkit\u002Fskills\u002Fmvvm\u002FSKILL.md",true,[77,83,87,91],{"path":78,"resourceType":79,"resourceTypeDesc":80,"sizeBytes":81,"sourceHtmlUrl":82},"manifest.json","REFERENCE","参考文档",60,"https:\u002F\u002Fgithub.com\u002Fmanagedcode\u002Fdotnet-skills\u002Fblob\u002Fmain\u002Fcatalog\u002FLibraries\u002FMVVM-Toolkit\u002Fskills\u002Fmvvm\u002Fmanifest.json",{"path":84,"resourceType":79,"resourceTypeDesc":80,"sizeBytes":85,"sourceHtmlUrl":86},"references\u002Fanti-patterns.md",6460,"https:\u002F\u002Fgithub.com\u002Fmanagedcode\u002Fdotnet-skills\u002Fblob\u002Fmain\u002Fcatalog\u002FLibraries\u002FMVVM-Toolkit\u002Fskills\u002Fmvvm\u002Freferences\u002Fanti-patterns.md",{"path":88,"resourceType":79,"resourceTypeDesc":80,"sizeBytes":89,"sourceHtmlUrl":90},"references\u002Fpatterns.md",7037,"https:\u002F\u002Fgithub.com\u002Fmanagedcode\u002Fdotnet-skills\u002Fblob\u002Fmain\u002Fcatalog\u002FLibraries\u002FMVVM-Toolkit\u002Fskills\u002Fmvvm\u002Freferences\u002Fpatterns.md",{"path":92,"resourceType":79,"resourceTypeDesc":80,"sizeBytes":93,"sourceHtmlUrl":94},"references\u002Freview-output-template.md",2466,"https:\u002F\u002Fgithub.com\u002Fgjbvsjjvgm-sketch\u002Fhermes-sovereign-unified-v13.6\u002Fblob\u002Fmain\u002Fhermes_sovereign_data\u002Fskills\u002Fgithub\u002Fgithub-code-review\u002Freferences\u002Freview-output-template.md",[96,125,146,177,187,214],{"skillNo":97,"name":98,"nameZh":6,"description":99,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":100,"categories":101,"keywords":110,"publishedAt":47},"01M6DYQE1Y9FHAQHEDTVFQ3447","xtwitter-scraper","Use XTwitterScraper when a .NET application needs typed access to Xquik's X automation REST API for tweet search, user lookup, posting workflows, extraction jobs, monitors, webhooks, or giveaway draws. USE FOR: integrating the XTwitterScraper NuGet package; reviewing Xquik API client usage; modeling API-key configuration, pagination, binary exports, raw responses, retries, and webhook\u002Fevent flows in .NET. DO NOT USE FOR: unrelated stacks; direct browser automation; generic social-media strategy; or code that does not call Xquik. INVOKES: inspect the repository context, edit targeted files, and run relevant build, test, lint, or validation commands when changes are made.","https:\u002F\u002Fgithub.com\u002Fmanagedcode\u002Fdotnet-skills\u002Fblob\u002Fmain\u002Fcatalog\u002FLibraries\u002FXTwitterScraper\u002Fskills\u002Fxtwitter-scraper\u002FSKILL.md",[102,105],{"categoryNo":103,"categoryName":104,"taxonomyType":21,"taxonomyTypeDesc":22},"01JBSEEDCAT000000000000010","后端与接口",{"categoryNo":106,"categoryName":107,"taxonomyType":108,"taxonomyTypeDesc":109},"01JBSEEDCAT000000000000030","开发工程师","PROFESSION","适用职业",[111,112,113,45,114,115,116,42,117,118,119,120,37,35,121,34,122,31,123,124],"xtwitter scraper","browser automation","workflows","code","browser","search","api","Media","api client","access","webhooks","social","modeling","webhook",{"skillNo":126,"name":127,"nameZh":6,"description":128,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":129,"categories":130,"keywords":137,"publishedAt":47},"01M6DYQ9S4PE1H6G8MCH9T21HR","sep","Use Sep for high-performance separated-value parsing and writing in .NET, including delimiter inference, explicit parser\u002Fwriter options, and low-allocation row\u002Fcolumn workflows. USE FOR: delimited data needs are performance-sensitive and allocation-aware; project needs explicit control over separator inference, escaping, trimming, and header behavior;. DO NOT USE FOR: unrelated stacks; generic tasks that do not need this specific guidance. INVOKES: inspect the repository context, edit targeted files, and run relevant build, test, lint, or validation commands when changes are made.","https:\u002F\u002Fgithub.com\u002Fmanagedcode\u002Fdotnet-skills\u002Fblob\u002Fmain\u002Fcatalog\u002FLibraries\u002FSep\u002Fskills\u002Fsep\u002FSKILL.md",[131,134],{"categoryNo":132,"categoryName":133,"taxonomyType":21,"taxonomyTypeDesc":22},"01JBSEEDCAT000000000000018","写作与文案",{"categoryNo":135,"categoryName":136,"taxonomyType":108,"taxonomyTypeDesc":109},"01JBSEEDCAT000000000000036","内容创作者",[127,138,139,113,46,45,42,41,140,141,37,36,35,34,33,142,143,144,31,145],"writing","performance","parsing","parser","writer","options","project","high-performance",{"skillNo":147,"name":148,"nameZh":6,"description":149,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":150,"categories":151,"keywords":152,"publishedAt":47},"01M6DZS2DNEPXCGGF6SSCW6G5V","webgpu-threejs-tsl","Comprehensive guide for developing WebGPU-enabled Three.js applications using TSL (Three.js Shading Language). Covers WebGPU renderer setup, TSL syntax and node materials, compute shaders, post-processing effects, and WGSL integration. Use this skill when working with Three.js WebGPU, TSL shaders, node materials, or GPU compute in Three.js.","https:\u002F\u002Fgithub.com\u002Fmanagedcode\u002Fdotnet-skills\u002Fblob\u002Fmain\u002Fexternal-sources\u002Fupstreams\u002Fwebgpu-claude-skill\u002Fskills\u002Fwebgpu-threejs-tsl\u002FSKILL.md",[],[153,154,155,156,157,158,159,160,161,162,163,164,165,166,167,168,169,170,171,172,173,174,175,176,24],"webgpu","threejs","webgpu threejs tsl","setup","shaders","gpu","integration","applications","js","node","syntax","guide","use","language","three","compute","post","processing","with","renderer","for","materials","wgsl","effects",{"skillNo":178,"name":179,"nameZh":6,"description":180,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":181,"categories":182,"keywords":183,"publishedAt":47},"01M6DZS0BQXW2B56A289XF1X76","roslynk","Use Roslynk for semantic inspection and edits of *.cs, *.razor and *.cshtml solution files.","https:\u002F\u002Fgithub.com\u002Fmanagedcode\u002Fdotnet-skills\u002Fblob\u002Fmain\u002Fexternal-sources\u002Fupstreams\u002Froslynk\u002Fskills\u002Froslynk\u002FSKILL.md",[],[179,165,34,184,185,173,186],"semantic","razor","inspection",{"skillNo":188,"name":189,"nameZh":6,"description":190,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":191,"categories":192,"keywords":193,"publishedAt":47},"01M6DZRW6MEJCVW80K3S4XV60K","system-text-json-net11","Imperative guidance for the System.Text.Json APIs added in .NET 11: the built-in `JsonNamingPolicy.PascalCase` naming policy, and the strongly-typed generic `JsonSerializerOptions.GetTypeInfo` and `JsonSerializerOptions.TryGetTypeInfo` metadata accessors (generic overloads that return a typed `JsonTypeInfo`). USE ONLY when the user is targeting net11.0 or later and needs PascalCase JSON property or dictionary-key names without writing a custom naming policy, a strongly-typed generic `JsonTypeInfo` instead of the non-generic `JsonTypeInfo`, or a no-throw way to probe whether a type's serialization metadata is resolved. DO NOT USE when the target is earlier than net11.0, the requested behavior uses an established pre-net11 naming policy, or the user explicitly selected another JSON library.","https:\u002F\u002Fgithub.com\u002Fmanagedcode\u002Fdotnet-skills\u002Fblob\u002Fmain\u002Fexternal-sources\u002Fupstreams\u002Fdotnet-skills\u002Fplugins\u002Fdotnet11\u002Fskills\u002Fsystem-text-json-net11\u002FSKILL.md",[],[194,195,196,197,138,198,199,200,201,202,203,165,204,205,206,207,33,208,209,210,211,173,212,213,24],"system","json","text","system text json net11","policy","metadata","library","serialization","behavior","user","only","probe","guidance","later","type","dictionary","naming","targeting","custom","generic",{"skillNo":215,"name":216,"nameZh":6,"description":217,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":218,"categories":219,"keywords":222,"publishedAt":47},"01M6DZRRJP3S662NFSG1RSPQQ7","process-api-net11","Provides guidance on the new System.Diagnostics.Process APIs introduced in .NET 11: Process.Run, Process.RunAndCaptureText, Process.StartAndForget, Process.ReadAllText\u002FBytes\u002FLines, KillOnParentExit, InheritedHandles, and StartDetached. USE FOR: starting, orchestrating, or capturing output from external processes in applications targeting net11.0 or later. DO NOT USE FOR: applications targeting .NET 10 or earlier, or basic pre-.NET 11 Process.Start usage without new APIs.","https:\u002F\u002Fgithub.com\u002Fmanagedcode\u002Fdotnet-skills\u002Fblob\u002Fmain\u002Fexternal-sources\u002Fupstreams\u002Fdotnet-skills\u002Fplugins\u002Fdotnet11\u002Fskills\u002Fprocess-api-net11\u002FSKILL.md",[220,221],{"categoryNo":103,"categoryName":104,"taxonomyType":21,"taxonomyTypeDesc":22},{"categoryNo":106,"categoryName":107,"taxonomyType":108,"taxonomyTypeDesc":109},[117,223,224,225,45,226,160,194,165,206,207,33,227,228,229,230,211,173,231],"process","process api net11","diagnostics","start","basic","processes","output","usage","new"]