[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M6DYMC23QW8Y7CR3C2MKCFV0":3,"skill-same:01M6DYMC23QW8Y7CR3C2MKCFV0":90},{"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":46,"linkOnly":47,"markdownContent":48,"markdownBody":49,"frontMatter":50,"refName":52,"commitSha":53,"skillDirectory":54,"forksCount":55,"repositoryHtmlUrl":56,"repositoryHomepageUrl":57,"ownerHtmlUrl":58,"ownerBlogUrl":59,"ownerDescription":60,"updatedAt":61,"install":62,"resources":75},"01M6DYMC23QW8Y7CR3C2MKCFV0","wpf",null,"Build and modernize WPF applications on .NET with correct XAML, data binding, commands, threading, styling, and Windows desktop migration decisions. USE FOR: working on WPF UI, MVVM, binding, commands, or desktop modernization; migrating WPF from .NET Framework to .NET; integrating newer Windows capabilities into a WPF app. 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\u002FFrameworks\u002FWPF\u002Fskills\u002Fwpf\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],"edit","when","inspect","relevant","app","commands","project","do","files","unrelated","styling","context","windows","data","repository","ui","framework","capabilities","xaml","run","tasks","modernization","2026-11-10 10:12:30",false,"---\nname: wpf\ndescription: \"Build and modernize WPF applications on .NET with correct XAML, data binding, commands, threading, styling, and Windows desktop migration decisions. USE FOR: working on WPF UI, MVVM, binding, commands, or desktop modernization; migrating WPF from .NET Framework to .NET; integrating newer Windows capabilities into a WPF app. 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: \"Requires a WPF project on .NET or .NET Framework.\"\n---\n\n# WPF\n\n## Trigger On\n\n- working on WPF UI, MVVM, binding, commands, or desktop modernization\n- migrating WPF from .NET Framework to .NET\n- integrating newer Windows capabilities into a WPF app\n- implementing data binding, styles, templates, or control customization\n- connecting desktop applications with backend agent services and [building AI agents with .NET](https:\u002F\u002Fmanaged-code.com\u002Fblog-post\u002Fbuilding-ai-agents-with-csharp-dotnet)\n\n## Documentation\n\n- [WPF Overview](https:\u002F\u002Flearn.microsoft.com\u002Fen-us\u002Fdotnet\u002Fdesktop\u002Fwpf\u002Foverview\u002F)\n- [Data Binding Overview](https:\u002F\u002Flearn.microsoft.com\u002Fen-us\u002Fdotnet\u002Fdesktop\u002Fwpf\u002Fdata\u002F)\n- [MVVM Toolkit Introduction](https:\u002F\u002Flearn.microsoft.com\u002Fen-us\u002Fdotnet\u002Fcommunitytoolkit\u002Fmvvm\u002F)\n- [Styles and Templates](https:\u002F\u002Flearn.microsoft.com\u002Fen-us\u002Fdotnet\u002Fdesktop\u002Fwpf\u002Fcontrols\u002Fstyles-templates-overview)\n- [Migration Guide](https:\u002F\u002Flearn.microsoft.com\u002Fen-us\u002Fdotnet\u002Fdesktop\u002Fwpf\u002Fmigration\u002F)\n\n## References\n\n- [building AI agents with .NET](https:\u002F\u002Fmanaged-code.com\u002Fblog-post\u002Fbuilding-ai-agents-with-csharp-dotnet) - Architecture and implementation patterns for production AI agents on .NET.\n- [.NET AI agent development team](https:\u002F\u002Fmanaged-code.com\u002Fservices\u002Fai-agents) - Production .NET AI agent engineering and delivery services.\n- [patterns.md](references\u002Fpatterns.md) - MVVM patterns, binding patterns, command patterns, and reusable architectural approaches\n- [anti-patterns.md](references\u002Fanti-patterns.md) - Common WPF mistakes and how to avoid them\n\n## Workflow\n\n1. **Confirm Windows-only scope** — WPF is Windows-only even when the wider .NET stack is cross-platform\n2. **Apply MVVM pattern** — keep views dumb, logic in ViewModels, use commands\n3. **Manage data binding explicitly** — choose correct binding modes, validate at runtime\n4. **Use styles and templates deliberately** — keep UI composable, avoid page-specific hacks\n5. **Handle threading correctly** — use Dispatcher for UI updates, async\u002Fawait for long operations\n6. **Validate both designer and runtime** — XAML composition failures often surface only at runtime\n\n## Current Upstream Notes\n\n- The August 2026 WPF overview reiterates WPF as a Windows-only desktop UI stack with XAML, data binding, styling, templates, resources, and vector\u002Frich-media composition. Keep WPF-specific guidance separate from WinUI or MAUI unless the task is explicitly a migration or comparison.\n- WPF exists on both .NET Framework and modern .NET. For modernization work, inventory compatibility constraints and use the current desktop migration guidance before moving project files, interop, deployment, or XAML resource dictionaries.\n\n## Project Structure\n\n```\nMyWpfApp\u002F\n├── MyWpfApp\u002F\n│   ├── App.xaml                # Application entry\n│   ├── MainWindow.xaml         # Main window\n│   ├── Views\u002F                  # XAML views\u002Fwindows\n│   ├── ViewModels\u002F             # MVVM ViewModels\n│   ├── Models\u002F                 # Domain models\n│   ├── Services\u002F               # Business logic\n│   ├── Converters\u002F             # Value converters\n│   ├── Resources\u002F              # Styles, templates, dictionaries\n│   └── Controls\u002F               # Custom controls\n└── MyWpfApp.Tests\u002F\n```\n\n## MVVM Pattern\n\n### ViewModel with MVVM Toolkit\n```csharp\npublic partial class CustomersViewModel : ObservableObject\n{\n    private readonly ICustomerService _customerService;\n\n    [ObservableProperty]\n    private ObservableCollection\u003CCustomer> _customers = [];\n\n    [ObservableProperty]\n    [NotifyCanExecuteChangedFor(nameof(SaveCommand))]\n    private Customer? _selectedCustomer;\n\n    [ObservableProperty]\n    [NotifyCanExecuteChangedFor(nameof(RefreshCommand))]\n    private bool _isLoading;\n\n    public CustomersViewModel(ICustomerService customerService)\n    {\n        _customerService = customerService;\n    }\n\n    [RelayCommand(CanExecute = nameof(CanRefresh))]\n    private async Task RefreshAsync()\n    {\n        IsLoading = true;\n        try\n        {\n            var items = await _customerService.GetAllAsync();\n            Customers = new ObservableCollection\u003CCustomer>(items);\n        }\n        finally\n        {\n            IsLoading = false;\n        }\n    }\n\n    private bool CanRefresh() => !IsLoading;\n\n    [RelayCommand(CanExecute = nameof(CanSave))]\n    private async Task SaveAsync()\n    {\n        if (SelectedCustomer is null) return;\n        await _customerService.SaveAsync(SelectedCustomer);\n    }\n\n    private bool CanSave() => SelectedCustomer is not null;\n}\n```\n\n### View Binding\n```xml\n\u003CWindow x:Class=\"MyWpfApp.Views.CustomersView\"\n        xmlns=\"http:\u002F\u002Fschemas.microsoft.com\u002Fwinfx\u002F2006\u002Fxaml\u002Fpresentation\"\n        xmlns:x=\"http:\u002F\u002Fschemas.microsoft.com\u002Fwinfx\u002F2006\u002Fxaml\"\n        xmlns:vm=\"clr-namespace:MyWpfApp.ViewModels\"\n        d:DataContext=\"{d:DesignInstance Type=vm:CustomersViewModel}\">\n\n    \u003CGrid>\n        \u003CGrid.RowDefinitions>\n            \u003CRowDefinition Height=\"Auto\"\u002F>\n            \u003CRowDefinition Height=\"*\"\u002F>\n        \u003C\u002FGrid.RowDefinitions>\n\n        \u003CToolBar Grid.Row=\"0\">\n            \u003CButton Content=\"Refresh\"\n                    Command=\"{Binding RefreshCommand}\"\u002F>\n            \u003CButton Content=\"Save\"\n                    Command=\"{Binding SaveCommand}\"\u002F>\n        \u003C\u002FToolBar>\n\n        \u003CDataGrid Grid.Row=\"1\"\n                  ItemsSource=\"{Binding Customers}\"\n                  SelectedItem=\"{Binding SelectedCustomer}\"\n                  AutoGenerateColumns=\"False\">\n            \u003CDataGrid.Columns>\n                \u003CDataGridTextColumn Header=\"Name\"\n                                    Binding=\"{Binding Name}\"\u002F>\n                \u003CDataGridTextColumn Header=\"Email\"\n                                    Binding=\"{Binding Email}\"\u002F>\n            \u003C\u002FDataGrid.Columns>\n        \u003C\u002FDataGrid>\n    \u003C\u002FGrid>\n\u003C\u002FWindow>\n```\n\n## Dependency Injection\n\n```csharp\npublic partial class App : Application\n{\n    private readonly IHost _host;\n\n    public App()\n    {\n        _host = Host.CreateDefaultBuilder()\n            .ConfigureServices((context, services) =>\n            {\n                \u002F\u002F Services\n                services.AddSingleton\u003CICustomerService, CustomerService>();\n                services.AddSingleton\u003CINavigationService, NavigationService>();\n\n                \u002F\u002F ViewModels\n                services.AddTransient\u003CCustomersViewModel>();\n                services.AddTransient\u003CCustomerDetailViewModel>();\n\n                \u002F\u002F Views\n                services.AddTransient\u003CMainWindow>();\n                services.AddTransient\u003CCustomersView>();\n            })\n            .Build();\n    }\n\n    protected override async void OnStartup(StartupEventArgs e)\n    {\n        await _host.StartAsync();\n        var mainWindow = _host.Services.GetRequiredService\u003CMainWindow>();\n        mainWindow.Show();\n        base.OnStartup(e);\n    }\n\n    protected override async void OnExit(ExitEventArgs e)\n    {\n        await _host.StopAsync();\n        _host.Dispose();\n        base.OnExit(e);\n    }\n}\n```\n\n## Data Binding Modes\n\n```xml\n\u003C!-- OneTime: Read once at initialization -->\n\u003CTextBlock Text=\"{Binding CreatedDate, Mode=OneTime}\"\u002F>\n\n\u003C!-- OneWay: Source to target only (default for most properties) -->\n\u003CTextBlock Text=\"{Binding Name, Mode=OneWay}\"\u002F>\n\n\u003C!-- TwoWay: Bidirectional synchronization -->\n\u003CTextBox Text=\"{Binding Name, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}\"\u002F>\n\n\u003C!-- OneWayToSource: Target to source only -->\n\u003CTextBox Text=\"{Binding SearchFilter, Mode=OneWayToSource}\"\u002F>\n```\n\n## Value Converters\n\n```csharp\npublic class BooleanToVisibilityConverter : IValueConverter\n{\n    public object Convert(object value, Type targetType, object parameter, CultureInfo culture)\n    {\n        if (value is bool boolValue)\n        {\n            return boolValue ? Visibility.Visible : Visibility.Collapsed;\n        }\n        return Visibility.Collapsed;\n    }\n\n    public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)\n    {\n        return value is Visibility.Visible;\n    }\n}\n\n\u002F\u002F Multi-value converter\npublic class MultiplyConverter : IMultiValueConverter\n{\n    public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture)\n    {\n        if (values.Length == 2 && values[0] is double a && values[1] is double b)\n        {\n            return a * b;\n        }\n        return 0.0;\n    }\n\n    public object[] ConvertBack(object value, Type[] targetTypes, object parameter, CultureInfo culture)\n    {\n        throw new NotImplementedException();\n    }\n}\n```\n\n## Styles and Templates\n\n### Resource Dictionary\n```xml\n\u003CResourceDictionary xmlns=\"http:\u002F\u002Fschemas.microsoft.com\u002Fwinfx\u002F2006\u002Fxaml\u002Fpresentation\"\n                    xmlns:x=\"http:\u002F\u002Fschemas.microsoft.com\u002Fwinfx\u002F2006\u002Fxaml\">\n\n    \u003C!-- Implicit style for all Buttons -->\n    \u003CStyle TargetType=\"Button\">\n        \u003CSetter Property=\"Padding\" Value=\"10,5\"\u002F>\n        \u003CSetter Property=\"Margin\" Value=\"5\"\u002F>\n        \u003CSetter Property=\"Background\" Value=\"#0078D4\"\u002F>\n        \u003CSetter Property=\"Foreground\" Value=\"White\"\u002F>\n        \u003CSetter Property=\"Template\">\n            \u003CSetter.Value>\n                \u003CControlTemplate TargetType=\"Button\">\n                    \u003CBorder Background=\"{TemplateBinding Background}\"\n                            CornerRadius=\"4\"\n                            Padding=\"{TemplateBinding Padding}\">\n                        \u003CContentPresenter HorizontalAlignment=\"Center\"\n                                          VerticalAlignment=\"Center\"\u002F>\n                    \u003C\u002FBorder>\n                \u003C\u002FControlTemplate>\n            \u003C\u002FSetter.Value>\n        \u003C\u002FSetter>\n    \u003C\u002FStyle>\n\n    \u003C!-- Named style -->\n    \u003CStyle x:Key=\"DangerButton\" TargetType=\"Button\" BasedOn=\"{StaticResource {x:Type Button}}\">\n        \u003CSetter Property=\"Background\" Value=\"#D32F2F\"\u002F>\n    \u003C\u002FStyle>\n\u003C\u002FResourceDictionary>\n```\n\n## Threading and Dispatcher\n\n```csharp\n\u002F\u002F Update UI from background thread\nawait Task.Run(async () =>\n{\n    var data = await LoadDataAsync();\n\n    \u002F\u002F Must use Dispatcher to update UI\n    Application.Current.Dispatcher.Invoke(() =>\n    {\n        Items.Clear();\n        foreach (var item in data)\n        {\n            Items.Add(item);\n        }\n    });\n});\n\n\u002F\u002F Better: Use async\u002Fawait properly\nprivate async Task LoadDataAsync()\n{\n    IsLoading = true;\n    try\n    {\n        \u002F\u002F This runs on background thread\n        var data = await _service.GetDataAsync();\n\n        \u002F\u002F This automatically marshals to UI thread\n        Items = new ObservableCollection\u003CItem>(data);\n    }\n    finally\n    {\n        IsLoading = false;\n    }\n}\n```\n\n## Anti-Patterns to Avoid\n\n| Anti-Pattern | Why It's Bad | Better Approach |\n|--------------|--------------|-----------------|\n| Logic in code-behind | Hard to test, tight coupling | Use MVVM with ViewModels |\n| Synchronous blocking calls | UI freezes | Use async\u002Fawait |\n| Manual INotifyPropertyChanged | Boilerplate, error-prone | Use MVVM Toolkit attributes |\n| Hardcoded colors\u002Fsizes | Inconsistent, hard to theme | Use resource dictionaries |\n| Direct Dispatcher.Invoke everywhere | Complex, error-prone | Prefer async\u002Fawait marshaling |\n| God ViewModel | Unmaintainable | Split into focused ViewModels |\n| Skipping binding validation | Runtime errors hidden | Use ValidatesOnDataErrors |\n| Event handlers for everything | Memory leaks, coupling | Use commands and bindings |\n\n## Best Practices\n\n1. **Use compiled bindings in .NET 5+:**\n   - Enable `x:CompileBindings=\"True\"` for performance\n\n2. **Implement INotifyDataErrorInfo for validation:**\n   ```csharp\n   [ObservableProperty]\n   [NotifyDataErrorInfo]\n   [Required(ErrorMessage = \"Name is required\")]\n   [MinLength(2, ErrorMessage = \"Name must be at least 2 characters\")]\n   private string _name = string.Empty;\n   ```\n\n3. **Use weak event patterns for long-lived subscriptions:**\n   ```csharp\n   WeakEventManager\u003CSource, EventArgs>.AddHandler(source, \"EventName\", Handler);\n   ```\n\n4. **Virtualize large collections:**\n   ```xml\n   \u003CListBox VirtualizingPanel.IsVirtualizing=\"True\"\n            VirtualizingPanel.VirtualizationMode=\"Recycling\"\n            ItemsSource=\"{Binding LargeCollection}\"\u002F>\n   ```\n\n5. **Freeze Freezables when possible:**\n   ```csharp\n   var brush = new SolidColorBrush(Colors.Blue);\n   brush.Freeze(); \u002F\u002F Thread-safe, better performance\n   ```\n\n6. **Use design-time data:**\n   ```xml\n   \u003CWindow d:DataContext=\"{d:DesignInstance Type=vm:MainViewModel, IsDesignTimeCreatable=True}\">\n   ```\n\n## Testing\n\n```csharp\n[Fact]\npublic async Task RefreshCommand_LoadsCustomers()\n{\n    var mockService = new Mock\u003CICustomerService>();\n    mockService.Setup(s => s.GetAllAsync())\n        .ReturnsAsync(new[] { new Customer { Name = \"Test\" } });\n\n    var viewModel = new CustomersViewModel(mockService.Object);\n\n    await viewModel.RefreshCommand.ExecuteAsync(null);\n\n    Assert.Single(viewModel.Customers);\n    Assert.Equal(\"Test\", viewModel.Customers[0].Name);\n}\n\n[Fact]\npublic void SaveCommand_CannotExecute_WhenNoSelection()\n{\n    var mockService = new Mock\u003CICustomerService>();\n    var viewModel = new CustomersViewModel(mockService.Object);\n\n    viewModel.SelectedCustomer = null;\n\n    Assert.False(viewModel.SaveCommand.CanExecute(null));\n}\n```\n\n## Deliver\n\n- cleaner WPF views and view-model boundaries\n- safer binding and threading behavior\n- migration guidance grounded in actual Windows constraints\n- MVVM pattern with testable ViewModels\n\n## Validate\n\n- binding and command flows are explicit\n- code-behind is not carrying hidden business logic\n- Windows-only assumptions are acknowledged\n- threading and dispatcher usage is correct\n- styles and resources are properly organized\n","# WPF\n\n## Trigger On\n\n- working on WPF UI, MVVM, binding, commands, or desktop modernization\n- migrating WPF from .NET Framework to .NET\n- integrating newer Windows capabilities into a WPF app\n- implementing data binding, styles, templates, or control customization\n- connecting desktop applications with backend agent services and [building AI agents with .NET](https:\u002F\u002Fmanaged-code.com\u002Fblog-post\u002Fbuilding-ai-agents-with-csharp-dotnet)\n\n## Documentation\n\n- [WPF Overview](https:\u002F\u002Flearn.microsoft.com\u002Fen-us\u002Fdotnet\u002Fdesktop\u002Fwpf\u002Foverview\u002F)\n- [Data Binding Overview](https:\u002F\u002Flearn.microsoft.com\u002Fen-us\u002Fdotnet\u002Fdesktop\u002Fwpf\u002Fdata\u002F)\n- [MVVM Toolkit Introduction](https:\u002F\u002Flearn.microsoft.com\u002Fen-us\u002Fdotnet\u002Fcommunitytoolkit\u002Fmvvm\u002F)\n- [Styles and Templates](https:\u002F\u002Flearn.microsoft.com\u002Fen-us\u002Fdotnet\u002Fdesktop\u002Fwpf\u002Fcontrols\u002Fstyles-templates-overview)\n- [Migration Guide](https:\u002F\u002Flearn.microsoft.com\u002Fen-us\u002Fdotnet\u002Fdesktop\u002Fwpf\u002Fmigration\u002F)\n\n## References\n\n- [building AI agents with .NET](https:\u002F\u002Fmanaged-code.com\u002Fblog-post\u002Fbuilding-ai-agents-with-csharp-dotnet) - Architecture and implementation patterns for production AI agents on .NET.\n- [.NET AI agent development team](https:\u002F\u002Fmanaged-code.com\u002Fservices\u002Fai-agents) - Production .NET AI agent engineering and delivery services.\n- [patterns.md](references\u002Fpatterns.md) - MVVM patterns, binding patterns, command patterns, and reusable architectural approaches\n- [anti-patterns.md](references\u002Fanti-patterns.md) - Common WPF mistakes and how to avoid them\n\n## Workflow\n\n1. **Confirm Windows-only scope** — WPF is Windows-only even when the wider .NET stack is cross-platform\n2. **Apply MVVM pattern** — keep views dumb, logic in ViewModels, use commands\n3. **Manage data binding explicitly** — choose correct binding modes, validate at runtime\n4. **Use styles and templates deliberately** — keep UI composable, avoid page-specific hacks\n5. **Handle threading correctly** — use Dispatcher for UI updates, async\u002Fawait for long operations\n6. **Validate both designer and runtime** — XAML composition failures often surface only at runtime\n\n## Current Upstream Notes\n\n- The August 2026 WPF overview reiterates WPF as a Windows-only desktop UI stack with XAML, data binding, styling, templates, resources, and vector\u002Frich-media composition. Keep WPF-specific guidance separate from WinUI or MAUI unless the task is explicitly a migration or comparison.\n- WPF exists on both .NET Framework and modern .NET. For modernization work, inventory compatibility constraints and use the current desktop migration guidance before moving project files, interop, deployment, or XAML resource dictionaries.\n\n## Project Structure\n\n```\nMyWpfApp\u002F\n├── MyWpfApp\u002F\n│   ├── App.xaml                # Application entry\n│   ├── MainWindow.xaml         # Main window\n│   ├── Views\u002F                  # XAML views\u002Fwindows\n│   ├── ViewModels\u002F             # MVVM ViewModels\n│   ├── Models\u002F                 # Domain models\n│   ├── Services\u002F               # Business logic\n│   ├── Converters\u002F             # Value converters\n│   ├── Resources\u002F              # Styles, templates, dictionaries\n│   └── Controls\u002F               # Custom controls\n└── MyWpfApp.Tests\u002F\n```\n\n## MVVM Pattern\n\n### ViewModel with MVVM Toolkit\n```csharp\npublic partial class CustomersViewModel : ObservableObject\n{\n    private readonly ICustomerService _customerService;\n\n    [ObservableProperty]\n    private ObservableCollection\u003CCustomer> _customers = [];\n\n    [ObservableProperty]\n    [NotifyCanExecuteChangedFor(nameof(SaveCommand))]\n    private Customer? _selectedCustomer;\n\n    [ObservableProperty]\n    [NotifyCanExecuteChangedFor(nameof(RefreshCommand))]\n    private bool _isLoading;\n\n    public CustomersViewModel(ICustomerService customerService)\n    {\n        _customerService = customerService;\n    }\n\n    [RelayCommand(CanExecute = nameof(CanRefresh))]\n    private async Task RefreshAsync()\n    {\n        IsLoading = true;\n        try\n        {\n            var items = await _customerService.GetAllAsync();\n            Customers = new ObservableCollection\u003CCustomer>(items);\n        }\n        finally\n        {\n            IsLoading = false;\n        }\n    }\n\n    private bool CanRefresh() => !IsLoading;\n\n    [RelayCommand(CanExecute = nameof(CanSave))]\n    private async Task SaveAsync()\n    {\n        if (SelectedCustomer is null) return;\n        await _customerService.SaveAsync(SelectedCustomer);\n    }\n\n    private bool CanSave() => SelectedCustomer is not null;\n}\n```\n\n### View Binding\n```xml\n\u003CWindow x:Class=\"MyWpfApp.Views.CustomersView\"\n        xmlns=\"http:\u002F\u002Fschemas.microsoft.com\u002Fwinfx\u002F2006\u002Fxaml\u002Fpresentation\"\n        xmlns:x=\"http:\u002F\u002Fschemas.microsoft.com\u002Fwinfx\u002F2006\u002Fxaml\"\n        xmlns:vm=\"clr-namespace:MyWpfApp.ViewModels\"\n        d:DataContext=\"{d:DesignInstance Type=vm:CustomersViewModel}\">\n\n    \u003CGrid>\n        \u003CGrid.RowDefinitions>\n            \u003CRowDefinition Height=\"Auto\"\u002F>\n            \u003CRowDefinition Height=\"*\"\u002F>\n        \u003C\u002FGrid.RowDefinitions>\n\n        \u003CToolBar Grid.Row=\"0\">\n            \u003CButton Content=\"Refresh\"\n                    Command=\"{Binding RefreshCommand}\"\u002F>\n            \u003CButton Content=\"Save\"\n                    Command=\"{Binding SaveCommand}\"\u002F>\n        \u003C\u002FToolBar>\n\n        \u003CDataGrid Grid.Row=\"1\"\n                  ItemsSource=\"{Binding Customers}\"\n                  SelectedItem=\"{Binding SelectedCustomer}\"\n                  AutoGenerateColumns=\"False\">\n            \u003CDataGrid.Columns>\n                \u003CDataGridTextColumn Header=\"Name\"\n                                    Binding=\"{Binding Name}\"\u002F>\n                \u003CDataGridTextColumn Header=\"Email\"\n                                    Binding=\"{Binding Email}\"\u002F>\n            \u003C\u002FDataGrid.Columns>\n        \u003C\u002FDataGrid>\n    \u003C\u002FGrid>\n\u003C\u002FWindow>\n```\n\n## Dependency Injection\n\n```csharp\npublic partial class App : Application\n{\n    private readonly IHost _host;\n\n    public App()\n    {\n        _host = Host.CreateDefaultBuilder()\n            .ConfigureServices((context, services) =>\n            {\n                \u002F\u002F Services\n                services.AddSingleton\u003CICustomerService, CustomerService>();\n                services.AddSingleton\u003CINavigationService, NavigationService>();\n\n                \u002F\u002F ViewModels\n                services.AddTransient\u003CCustomersViewModel>();\n                services.AddTransient\u003CCustomerDetailViewModel>();\n\n                \u002F\u002F Views\n                services.AddTransient\u003CMainWindow>();\n                services.AddTransient\u003CCustomersView>();\n            })\n            .Build();\n    }\n\n    protected override async void OnStartup(StartupEventArgs e)\n    {\n        await _host.StartAsync();\n        var mainWindow = _host.Services.GetRequiredService\u003CMainWindow>();\n        mainWindow.Show();\n        base.OnStartup(e);\n    }\n\n    protected override async void OnExit(ExitEventArgs e)\n    {\n        await _host.StopAsync();\n        _host.Dispose();\n        base.OnExit(e);\n    }\n}\n```\n\n## Data Binding Modes\n\n```xml\n\u003C!-- OneTime: Read once at initialization -->\n\u003CTextBlock Text=\"{Binding CreatedDate, Mode=OneTime}\"\u002F>\n\n\u003C!-- OneWay: Source to target only (default for most properties) -->\n\u003CTextBlock Text=\"{Binding Name, Mode=OneWay}\"\u002F>\n\n\u003C!-- TwoWay: Bidirectional synchronization -->\n\u003CTextBox Text=\"{Binding Name, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}\"\u002F>\n\n\u003C!-- OneWayToSource: Target to source only -->\n\u003CTextBox Text=\"{Binding SearchFilter, Mode=OneWayToSource}\"\u002F>\n```\n\n## Value Converters\n\n```csharp\npublic class BooleanToVisibilityConverter : IValueConverter\n{\n    public object Convert(object value, Type targetType, object parameter, CultureInfo culture)\n    {\n        if (value is bool boolValue)\n        {\n            return boolValue ? Visibility.Visible : Visibility.Collapsed;\n        }\n        return Visibility.Collapsed;\n    }\n\n    public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)\n    {\n        return value is Visibility.Visible;\n    }\n}\n\n\u002F\u002F Multi-value converter\npublic class MultiplyConverter : IMultiValueConverter\n{\n    public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture)\n    {\n        if (values.Length == 2 && values[0] is double a && values[1] is double b)\n        {\n            return a * b;\n        }\n        return 0.0;\n    }\n\n    public object[] ConvertBack(object value, Type[] targetTypes, object parameter, CultureInfo culture)\n    {\n        throw new NotImplementedException();\n    }\n}\n```\n\n## Styles and Templates\n\n### Resource Dictionary\n```xml\n\u003CResourceDictionary xmlns=\"http:\u002F\u002Fschemas.microsoft.com\u002Fwinfx\u002F2006\u002Fxaml\u002Fpresentation\"\n                    xmlns:x=\"http:\u002F\u002Fschemas.microsoft.com\u002Fwinfx\u002F2006\u002Fxaml\">\n\n    \u003C!-- Implicit style for all Buttons -->\n    \u003CStyle TargetType=\"Button\">\n        \u003CSetter Property=\"Padding\" Value=\"10,5\"\u002F>\n        \u003CSetter Property=\"Margin\" Value=\"5\"\u002F>\n        \u003CSetter Property=\"Background\" Value=\"#0078D4\"\u002F>\n        \u003CSetter Property=\"Foreground\" Value=\"White\"\u002F>\n        \u003CSetter Property=\"Template\">\n            \u003CSetter.Value>\n                \u003CControlTemplate TargetType=\"Button\">\n                    \u003CBorder Background=\"{TemplateBinding Background}\"\n                            CornerRadius=\"4\"\n                            Padding=\"{TemplateBinding Padding}\">\n                        \u003CContentPresenter HorizontalAlignment=\"Center\"\n                                          VerticalAlignment=\"Center\"\u002F>\n                    \u003C\u002FBorder>\n                \u003C\u002FControlTemplate>\n            \u003C\u002FSetter.Value>\n        \u003C\u002FSetter>\n    \u003C\u002FStyle>\n\n    \u003C!-- Named style -->\n    \u003CStyle x:Key=\"DangerButton\" TargetType=\"Button\" BasedOn=\"{StaticResource {x:Type Button}}\">\n        \u003CSetter Property=\"Background\" Value=\"#D32F2F\"\u002F>\n    \u003C\u002FStyle>\n\u003C\u002FResourceDictionary>\n```\n\n## Threading and Dispatcher\n\n```csharp\n\u002F\u002F Update UI from background thread\nawait Task.Run(async () =>\n{\n    var data = await LoadDataAsync();\n\n    \u002F\u002F Must use Dispatcher to update UI\n    Application.Current.Dispatcher.Invoke(() =>\n    {\n        Items.Clear();\n        foreach (var item in data)\n        {\n            Items.Add(item);\n        }\n    });\n});\n\n\u002F\u002F Better: Use async\u002Fawait properly\nprivate async Task LoadDataAsync()\n{\n    IsLoading = true;\n    try\n    {\n        \u002F\u002F This runs on background thread\n        var data = await _service.GetDataAsync();\n\n        \u002F\u002F This automatically marshals to UI thread\n        Items = new ObservableCollection\u003CItem>(data);\n    }\n    finally\n    {\n        IsLoading = false;\n    }\n}\n```\n\n## Anti-Patterns to Avoid\n\n| Anti-Pattern | Why It's Bad | Better Approach |\n|--------------|--------------|-----------------|\n| Logic in code-behind | Hard to test, tight coupling | Use MVVM with ViewModels |\n| Synchronous blocking calls | UI freezes | Use async\u002Fawait |\n| Manual INotifyPropertyChanged | Boilerplate, error-prone | Use MVVM Toolkit attributes |\n| Hardcoded colors\u002Fsizes | Inconsistent, hard to theme | Use resource dictionaries |\n| Direct Dispatcher.Invoke everywhere | Complex, error-prone | Prefer async\u002Fawait marshaling |\n| God ViewModel | Unmaintainable | Split into focused ViewModels |\n| Skipping binding validation | Runtime errors hidden | Use ValidatesOnDataErrors |\n| Event handlers for everything | Memory leaks, coupling | Use commands and bindings |\n\n## Best Practices\n\n1. **Use compiled bindings in .NET 5+:**\n   - Enable `x:CompileBindings=\"True\"` for performance\n\n2. **Implement INotifyDataErrorInfo for validation:**\n   ```csharp\n   [ObservableProperty]\n   [NotifyDataErrorInfo]\n   [Required(ErrorMessage = \"Name is required\")]\n   [MinLength(2, ErrorMessage = \"Name must be at least 2 characters\")]\n   private string _name = string.Empty;\n   ```\n\n3. **Use weak event patterns for long-lived subscriptions:**\n   ```csharp\n   WeakEventManager\u003CSource, EventArgs>.AddHandler(source, \"EventName\", Handler);\n   ```\n\n4. **Virtualize large collections:**\n   ```xml\n   \u003CListBox VirtualizingPanel.IsVirtualizing=\"True\"\n            VirtualizingPanel.VirtualizationMode=\"Recycling\"\n            ItemsSource=\"{Binding LargeCollection}\"\u002F>\n   ```\n\n5. **Freeze Freezables when possible:**\n   ```csharp\n   var brush = new SolidColorBrush(Colors.Blue);\n   brush.Freeze(); \u002F\u002F Thread-safe, better performance\n   ```\n\n6. **Use design-time data:**\n   ```xml\n   \u003CWindow d:DataContext=\"{d:DesignInstance Type=vm:MainViewModel, IsDesignTimeCreatable=True}\">\n   ```\n\n## Testing\n\n```csharp\n[Fact]\npublic async Task RefreshCommand_LoadsCustomers()\n{\n    var mockService = new Mock\u003CICustomerService>();\n    mockService.Setup(s => s.GetAllAsync())\n        .ReturnsAsync(new[] { new Customer { Name = \"Test\" } });\n\n    var viewModel = new CustomersViewModel(mockService.Object);\n\n    await viewModel.RefreshCommand.ExecuteAsync(null);\n\n    Assert.Single(viewModel.Customers);\n    Assert.Equal(\"Test\", viewModel.Customers[0].Name);\n}\n\n[Fact]\npublic void SaveCommand_CannotExecute_WhenNoSelection()\n{\n    var mockService = new Mock\u003CICustomerService>();\n    var viewModel = new CustomersViewModel(mockService.Object);\n\n    viewModel.SelectedCustomer = null;\n\n    Assert.False(viewModel.SaveCommand.CanExecute(null));\n}\n```\n\n## Deliver\n\n- cleaner WPF views and view-model boundaries\n- safer binding and threading behavior\n- migration guidance grounded in actual Windows constraints\n- MVVM pattern with testable ViewModels\n\n## Validate\n\n- binding and command flows are explicit\n- code-behind is not carrying hidden business logic\n- Windows-only assumptions are acknowledged\n- threading and dispatcher usage is correct\n- styles and resources are properly organized\n",{"name":5,"description":7,"compatibility":51},"Requires a WPF project on .NET or .NET Framework.","main","497cc9aba79a931ac6fb8d36a48cc22fe3d6d74b","catalog\u002FFrameworks\u002FWPF\u002Fskills\u002Fwpf",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":63,"prompt":73,"zipAvailable":74},[64,67,70],{"tool":65,"command":66},"npx","npx skills add managedcode\u002Fdotnet-skills --skill wpf",{"tool":68,"command":69},"bunx","bunx skills add managedcode\u002Fdotnet-skills --skill wpf",{"tool":71,"command":72},"pnpm","pnpm dlx skills add managedcode\u002Fdotnet-skills --skill wpf","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002Fmanagedcode\u002Fdotnet-skills\u002Fblob\u002Fmain\u002Fcatalog\u002FFrameworks\u002FWPF\u002Fskills\u002Fwpf\u002FSKILL.md",true,[76,82,86],{"path":77,"resourceType":78,"resourceTypeDesc":79,"sizeBytes":80,"sourceHtmlUrl":81},"manifest.json","REFERENCE","参考文档",106,"https:\u002F\u002Fgithub.com\u002Fmanagedcode\u002Fdotnet-skills\u002Fblob\u002Fmain\u002Fcatalog\u002FFrameworks\u002FWPF\u002Fskills\u002Fwpf\u002Fmanifest.json",{"path":83,"resourceType":78,"resourceTypeDesc":79,"sizeBytes":84,"sourceHtmlUrl":85},"references\u002Fanti-patterns.md",18443,"https:\u002F\u002Fgithub.com\u002Fmanagedcode\u002Fdotnet-skills\u002Fblob\u002Fmain\u002Fcatalog\u002FFrameworks\u002FWPF\u002Fskills\u002Fwpf\u002Freferences\u002Fanti-patterns.md",{"path":87,"resourceType":78,"resourceTypeDesc":79,"sizeBytes":88,"sourceHtmlUrl":89},"references\u002Fpatterns.md",17847,"https:\u002F\u002Fgithub.com\u002Fmanagedcode\u002Fdotnet-skills\u002Fblob\u002Fmain\u002Fcatalog\u002FFrameworks\u002FWPF\u002Fskills\u002Fwpf\u002Freferences\u002Fpatterns.md",[91,120,140,171,181,208],{"skillNo":92,"name":93,"nameZh":6,"description":94,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":95,"categories":96,"keywords":105,"publishedAt":46},"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",[97,100],{"categoryNo":98,"categoryName":99,"taxonomyType":21,"taxonomyTypeDesc":22},"01JBSEEDCAT000000000000010","后端与接口",{"categoryNo":101,"categoryName":102,"taxonomyType":103,"taxonomyTypeDesc":104},"01JBSEEDCAT000000000000030","开发工程师","PROFESSION","适用职业",[106,107,108,43,109,110,111,38,112,113,114,115,24,33,116,32,117,29,118,119],"xtwitter scraper","browser automation","workflows","code","browser","search","api","Media","api client","access","webhooks","social","modeling","webhook",{"skillNo":121,"name":122,"nameZh":6,"description":123,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":124,"categories":125,"keywords":132,"publishedAt":46},"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",[126,129],{"categoryNo":127,"categoryName":128,"taxonomyType":21,"taxonomyTypeDesc":22},"01JBSEEDCAT000000000000018","写作与文案",{"categoryNo":130,"categoryName":131,"taxonomyType":103,"taxonomyTypeDesc":104},"01JBSEEDCAT000000000000036","内容创作者",[122,133,134,108,44,43,38,37,135,136,24,35,33,32,31,137,138,30,29,139],"writing","performance","parsing","parser","writer","options","high-performance",{"skillNo":141,"name":142,"nameZh":6,"description":143,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":144,"categories":145,"keywords":146,"publishedAt":46},"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",[],[147,148,149,150,151,152,153,154,155,156,157,158,159,160,161,162,163,164,165,166,167,168,169,170,25],"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":172,"name":173,"nameZh":6,"description":174,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":175,"categories":176,"keywords":177,"publishedAt":46},"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",[],[173,159,32,178,179,167,180],"semantic","razor","inspection",{"skillNo":182,"name":183,"nameZh":6,"description":184,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":185,"categories":186,"keywords":187,"publishedAt":46},"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",[],[188,189,190,191,133,192,193,194,195,196,197,159,198,199,200,201,31,202,203,204,205,167,206,207,25],"system","json","text","system text json net11","policy","metadata","library","serialization","behavior","user","only","probe","guidance","later","type","dictionary","naming","targeting","custom","generic",{"skillNo":209,"name":210,"nameZh":6,"description":211,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":212,"categories":213,"keywords":216,"publishedAt":46},"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",[214,215],{"categoryNo":98,"categoryName":99,"taxonomyType":21,"taxonomyTypeDesc":22},{"categoryNo":101,"categoryName":102,"taxonomyType":103,"taxonomyTypeDesc":104},[112,217,218,219,43,220,154,188,159,200,201,31,221,222,223,224,205,167,225],"process","process api net11","diagnostics","start","basic","processes","output","usage","new"]