[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M7CVAB4EKSJ4PE44ZW8KBXYP":3,"skill-same:01M7CVAB4EKSJ4PE44ZW8KBXYP":51},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":9,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":15,"categories":16,"keywords":17,"publishedAt":18,"linkOnly":19,"markdownContent":20,"markdownBody":21,"frontMatter":22,"refName":23,"commitSha":24,"skillDirectory":25,"forksCount":13,"repositoryHtmlUrl":26,"repositoryHomepageUrl":6,"ownerHtmlUrl":27,"ownerBlogUrl":28,"ownerDescription":29,"updatedAt":30,"install":31,"resources":44},"01M7CVAB4EKSJ4PE44ZW8KBXYP","maui-data-binding",null,"Guidance for .NET MAUI XAML and C# data bindings — compiled bindings, INotifyPropertyChanged \u002F ObservableObject, value converters, binding modes, multi-binding, relative bindings, fallbacks, and MVVM best practices. USE FOR: setting up compiled bindings with x:DataType, implementing INotifyPropertyChanged or CommunityToolkit ObservableObject, creating IValueConverter \u002F IMultiValueConverter, choosing binding modes, configuring BindingContext, relative bindings, binding fallbacks, StringFormat, code-behind SetBinding with lambdas, and enforcing XC0022\u002FXC0025 warnings. DO NOT USE FOR: CollectionView item templates and layouts (use maui-collectionview), Shell navigation data passing (use maui-shell-navigation), dependency injection (use maui-dependency-injection), or animations triggered by property changes (use .NET MAUI animation APIs).","deadmade\u002Fdead-agent-skills","deadmade","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F130925709?v=4","01M7CTQ65AGYR4J9K9TX0YR9V3","01M7CTQ66B4VMJFEDZP4EKKE6K",0,"MIT","https:\u002F\u002Fgithub.com\u002Fdeadmade\u002Fdead-agent-skills\u002Fblob\u002Fmain\u002Fplugins\u002Fopt-in\u002Fimplementation\u002Fcsharp-skills\u002Flibrary\u002Fmaui-data-binding\u002FSKILL.md",[],[],"2026-11-15 14:19:17",false,"---\nname: maui-data-binding\ndescription: >-\n  Guidance for .NET MAUI XAML and C# data bindings — compiled bindings,\n  INotifyPropertyChanged \u002F ObservableObject, value converters, binding modes,\n  multi-binding, relative bindings, fallbacks, and MVVM best practices.\n  USE FOR: setting up compiled bindings with x:DataType, implementing\n  INotifyPropertyChanged or CommunityToolkit ObservableObject, creating\n  IValueConverter \u002F IMultiValueConverter, choosing binding modes, configuring\n  BindingContext, relative bindings, binding fallbacks, StringFormat,\n  code-behind SetBinding with lambdas, and enforcing XC0022\u002FXC0025 warnings.\n  DO NOT USE FOR: CollectionView item templates and layouts (use\n  maui-collectionview), Shell navigation data passing (use\n  maui-shell-navigation), dependency injection (use maui-dependency-injection),\n  or animations triggered by property changes (use .NET MAUI animation APIs).\nlicense: MIT\n---\n\n# .NET MAUI Data Binding\n\nWire UI controls to ViewModel properties with compile-time safety, correct\nchange notification, and minimal overhead. Prefer compiled bindings everywhere\nand treat binding warnings as build errors.\n\n## When to Use\n\n- Adding `x:DataType` compiled bindings to a new or existing page\n- Implementing `INotifyPropertyChanged` or CommunityToolkit `ObservableObject`\n- Creating or consuming `IValueConverter` \u002F `IMultiValueConverter`\n- Choosing the correct `BindingMode` for a control property\n- Setting `BindingContext` in XAML or code-behind\n- Using relative bindings (`Self`, `AncestorType`, `TemplatedParent`)\n- Applying `StringFormat`, `FallbackValue`, or `TargetNullValue`\n- Writing AOT-safe code bindings with `SetBinding` and lambdas (.NET 9+)\n\n## When Not to Use\n\n- **CollectionView layouts \u002F templates** — use the `maui-collectionview` skill\n- **Shell navigation parameters** — use the `maui-shell-navigation` skill\n- **Service registration \u002F DI** — use the `maui-dependency-injection` skill\n- **Property-change-triggered animations** — use built-in [.NET MAUI animation APIs](https:\u002F\u002Flearn.microsoft.com\u002Fdotnet\u002Fmaui\u002Fuser-interface\u002Fanimation\u002Fbasic)\n\n## Inputs\n\n- A .NET MAUI project targeting .NET 8 or later\n- XAML pages or C# code-behind where bindings are declared\n- A ViewModel class (or plan to create one)\n\n## Rules That Change the Answer\n\nApply these to every binding answer — they are the differences between \"it compiles\"\nand \"it actually updates the UI\".\n\n| Situation | Do this | Not this |\n|---|---|---|\n| Deciding where `x:DataType` goes | Put it wherever a binding scope starts — the page\u002Fview root, and **each** `DataTemplate` | Scattering it on arbitrary children that share the parent's `BindingContext` |\n| A binding falls back to reflection (XC0022 \u002F XC0023) | Add the right `x:DataType` for that binding scope; for XC0023 remove the explicit `x:DataType=\"{x:Null}\"` | `x:DataType=\"x:Object\"` to silence it — this disables compile-time checking |\n| A `DataTemplate` inherits `x:DataType` from an outer scope (XC0024) | Give the `DataTemplate` its **own** `x:DataType` | Leaving it to resolve against the wrong type |\n| ViewModel change notification | `ObservableObject` + `[ObservableProperty]`, or implement `INotifyPropertyChanged` | A plain POCO base class — bindings will never update |\n| Bindings show blank | Check `BindingContext` is actually set | Assuming the binding path is wrong |\n| Enforcing compiled bindings | Set `MauiEnableXamlCBindingWithSourceCompilation` to `true`, **then** `\u003CWarningsAsErrors>XC0022;XC0025\u003C\u002FWarningsAsErrors>` | Promoting `XC0025` without the switch if the project uses `Source=` \u002F `RelativeSource` bindings |\n\n**Do not** restructure a ViewModel or add a converter that the user did not ask for\nand that fixes no real defect. Adding `x:DataType` is different: when you are\nalready editing a page's bindings, recommending compiled bindings is in scope.\n\n---\n\n## Compiled Bindings — x:DataType Placement\n\nCompiled bindings are **8–20× faster** than reflection-based bindings and are\nrequired for NativeAOT \u002F trimming. Enable them with `x:DataType`.\n\n### Placement rules\n\nSet `x:DataType` **only where `BindingContext` is set**:\n\n1. **Page \u002F View root** — where you assign `BindingContext`.\n2. **DataTemplate** — which creates a new binding scope.\n\nDo **not** scatter `x:DataType` on arbitrary child elements. Adding\n`x:DataType=\"x:Object\"` on children to escape compiled bindings is an\nanti-pattern — it disables compile-time checking and reintroduces reflection.\n\n```xml\n\u003C!-- ✅ Correct: x:DataType at the page root -->\n\u003CContentPage xmlns:vm=\"clr-namespace:MyApp.ViewModels\"\n             x:DataType=\"vm:MainViewModel\">\n    \u003CStackLayout>\n        \u003CLabel Text=\"{Binding Title}\" \u002F>\n        \u003CSlider Value=\"{Binding Progress}\" \u002F>\n    \u003C\u002FStackLayout>\n\u003C\u002FContentPage>\n\n\u003C!-- ❌ Wrong: x:DataType scattered on children -->\n\u003CContentPage x:DataType=\"vm:MainViewModel\">\n    \u003CStackLayout>\n        \u003CLabel Text=\"{Binding Title}\" \u002F>\n        \u003CSlider x:DataType=\"x:Object\" Value=\"{Binding Progress}\" \u002F>\n    \u003C\u002FStackLayout>\n\u003C\u002FContentPage>\n```\n\n### DataTemplate always needs its own x:DataType\n\n```xml\n\u003CCollectionView ItemsSource=\"{Binding People}\">\n    \u003CCollectionView.ItemTemplate>\n        \u003CDataTemplate x:DataType=\"model:Person\">\n            \u003CLabel Text=\"{Binding FullName}\" \u002F>\n        \u003C\u002FDataTemplate>\n    \u003C\u002FCollectionView.ItemTemplate>\n\u003C\u002FCollectionView>\n```\n\n### Enforce binding warnings as errors\n\n| Warning | Meaning |\n|---------|---------|\n| **XC0022** | Binding used **without `x:DataType` in scope** — not compiled, falls back to reflection |\n| **XC0023** | Binding not compiled because `x:DataType` is **explicitly `null`** |\n| **XC0024** | `x:DataType` came from an **outer scope** — annotate the `DataTemplate` with its own `x:DataType` |\n| **XC0025** | Binding not compiled because it has an explicit **`Source`** — enable `\u003CMauiEnableXamlCBindingWithSourceCompilation>` |\n\n> These four codes are **verified against .NET 10 \u002F .NET 11 MAUI**\n> (`Build.Tasks\u002FBuildException.cs`, `ErrorMessages.resx`). Diagnostic numbering is\n> SDK-band-sensitive — re-check against `BuildException.cs` before relying on it on a\n> newer SDK.\n\nAdd to the `.csproj`:\n\n```xml\n\u003C!-- Compile bindings that use Source= as well; otherwise XC0025 fires on every\n     Source= \u002F RelativeSource binding. As of .NET 10\u002F11 this is on by default\n     only for AOT \u002F full-trim builds. -->\n\u003CMauiEnableXamlCBindingWithSourceCompilation>true\u003C\u002FMauiEnableXamlCBindingWithSourceCompilation>\n\u003CWarningsAsErrors>XC0022;XC0025\u003C\u002FWarningsAsErrors>\n```\n\nIf you promote `XC0025` without enabling that switch, make sure the project has no\n`Source=` \u002F `RelativeSource` bindings — otherwise they will be reported.\n\n---\n\n## Binding Modes\n\nSet `Mode` explicitly **only** when overriding the default. Most properties\nalready have the correct default:\n\n| Mode | Direction | Use case |\n|------|-----------|----------|\n| `OneWay` | Source → Target | Display-only (default for most properties) |\n| `TwoWay` | Source ↔ Target | Editable controls (`Entry.Text`, `Switch.IsToggled`) |\n| `OneWayToSource` | Target → Source | Read user input without pushing back to UI |\n| `OneTime` | Source → Target (once) | Static values; no change-tracking overhead |\n\n```xml\n\u003C!-- ✅ Defaults — omit Mode -->\n\u003CLabel Text=\"{Binding Score}\" \u002F>\n\u003CEntry Text=\"{Binding UserName}\" \u002F>\n\u003CSwitch IsToggled=\"{Binding DarkMode}\" \u002F>\n\n\u003C!-- ✅ Override only when needed -->\n\u003CLabel Text=\"{Binding Title, Mode=OneTime}\" \u002F>\n\u003CEntry Text=\"{Binding SearchQuery, Mode=OneWayToSource}\" \u002F>\n\n\u003C!-- ❌ Redundant — adds noise -->\n\u003CLabel Text=\"{Binding Score, Mode=OneWay}\" \u002F>\n\u003CEntry Text=\"{Binding UserName, Mode=TwoWay}\" \u002F>\n```\n\n---\n\n## BindingContext and Property Paths\n\nEvery `BindableObject` inherits `BindingContext` from its parent unless\nexplicitly set. Property paths support dot notation and indexers:\n\n```xml\n\u003CLabel Text=\"{Binding Address.City}\" \u002F>\n\u003CLabel Text=\"{Binding Items[0].Name}\" \u002F>\n```\n\nSet `BindingContext` in XAML:\n\n```xml\n\u003CContentPage xmlns:vm=\"clr-namespace:MyApp.ViewModels\"\n             x:DataType=\"vm:MainViewModel\">\n    \u003CContentPage.BindingContext>\n        \u003Cvm:MainViewModel \u002F>\n    \u003C\u002FContentPage.BindingContext>\n\u003C\u002FContentPage>\n```\n\nOr in code-behind (preferred with DI):\n\n```csharp\npublic MainPage(MainViewModel vm)\n{\n    InitializeComponent();\n    BindingContext = vm;\n}\n```\n\n---\n\n## INotifyPropertyChanged and ObservableObject\n\n### Manual implementation\n\n```csharp\npublic class MainViewModel : INotifyPropertyChanged\n{\n    public event PropertyChangedEventHandler? PropertyChanged;\n\n    private string _title = string.Empty;\n    public string Title\n    {\n        get => _title;\n        set\n        {\n            if (_title != value)\n            {\n                _title = value;\n                PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(nameof(Title)));\n            }\n        }\n    }\n}\n```\n\n### CommunityToolkit.Mvvm (recommended)\n\n```csharp\nusing CommunityToolkit.Mvvm.ComponentModel;\nusing CommunityToolkit.Mvvm.Input;\n\npublic partial class MainViewModel : ObservableObject\n{\n    [ObservableProperty]\n    private string _title = string.Empty;\n\n    [RelayCommand]\n    private async Task LoadDataAsync() { \u002F* ... *\u002F }\n}\n```\n\nThe source generator creates the `Title` property, `PropertyChanged` raise,\nand `LoadDataCommand` automatically.\n\n---\n\n## Value Converters — IValueConverter\n\nImplement `Convert` (source → target) and `ConvertBack` (target → source):\n\n```csharp\npublic class IntToBoolConverter : IValueConverter\n{\n    public object? Convert(object? value, Type targetType,\n        object? parameter, CultureInfo culture)\n        => value is int i && i != 0;\n\n    public object? ConvertBack(object? value, Type targetType,\n        object? parameter, CultureInfo culture)\n        => value is true ? 1 : 0;\n}\n```\n\nDeclare in XAML resources and consume:\n\n```xml\n\u003CContentPage.Resources>\n    \u003Clocal:IntToBoolConverter x:Key=\"IntToBool\" \u002F>\n\u003C\u002FContentPage.Resources>\n\n\u003CSwitch IsToggled=\"{Binding Count, Converter={StaticResource IntToBool}}\" \u002F>\n```\n\n`ConverterParameter` is always passed as a **string** — parse inside `Convert`:\n\n```xml\n\u003CLabel Text=\"{Binding Score, Converter={StaticResource ThresholdConverter},\n              ConverterParameter=50}\" \u002F>\n```\n\n---\n\n## Multi-Binding\n\nCombine multiple source values with `IMultiValueConverter`:\n\n```xml\n\u003CLabel>\n    \u003CLabel.Text>\n        \u003CMultiBinding Converter=\"{StaticResource FullNameConverter}\">\n            \u003CBinding Path=\"FirstName\" \u002F>\n            \u003CBinding Path=\"LastName\" \u002F>\n        \u003C\u002FMultiBinding>\n    \u003C\u002FLabel.Text>\n\u003C\u002FLabel>\n```\n\n```csharp\npublic class FullNameConverter : IMultiValueConverter\n{\n    public object Convert(object[] values, Type targetType,\n        object parameter, CultureInfo culture)\n    {\n        if (values.Length == 2 && values[0] is string first\n            && values[1] is string last)\n            return $\"{first} {last}\";\n        return string.Empty;\n    }\n\n    public object[] ConvertBack(object value, Type[] targetTypes,\n        object parameter, CultureInfo culture)\n        => throw new NotSupportedException();\n}\n```\n\n---\n\n## Relative Bindings\n\n| Source | Syntax | Use case |\n|--------|--------|----------|\n| Self | `{Binding Source={RelativeSource Self}, Path=WidthRequest}` | Bind to own properties |\n| Ancestor | `{Binding BindingContext.Title, Source={RelativeSource AncestorType={x:Type ContentPage}}}` | Reach parent BindingContext |\n| TemplatedParent | `{Binding Source={RelativeSource TemplatedParent}, Path=Padding}` | Inside ControlTemplate |\n\n```xml\n\u003C!-- Square box: Height = Width -->\n\u003CBoxView WidthRequest=\"100\"\n         HeightRequest=\"{Binding Source={RelativeSource Self}, Path=WidthRequest}\" \u002F>\n```\n\n---\n\n## StringFormat\n\nUse `Binding.StringFormat` for simple display formatting without a converter:\n\n```xml\n\u003CLabel Text=\"{Binding Price, StringFormat='Total: {0:C2}'}\" \u002F>\n\u003CLabel Text=\"{Binding DueDate, StringFormat='{0:MMM dd, yyyy}'}\" \u002F>\n```\n\nWrap the format string in single quotes when it contains commas or braces.\n\n---\n\n## Binding Fallbacks\n\n- **FallbackValue** — used when the binding path cannot be resolved or the\n  converter throws.\n- **TargetNullValue** — used when the bound value is `null`.\n\n```xml\n\u003CLabel Text=\"{Binding MiddleName, TargetNullValue='(none)',\n              FallbackValue='unavailable'}\" \u002F>\n\u003CImage Source=\"{Binding AvatarUrl, TargetNullValue='default_avatar.png'}\" \u002F>\n```\n\n---\n\n## .NET 9+ Code Bindings (AOT-safe)\n\nFully AOT-safe, no reflection:\n\n```csharp\nlabel.SetBinding(Label.TextProperty,\n    static (PersonViewModel vm) => vm.FullName);\n\nentry.SetBinding(Entry.TextProperty,\n    static (PersonViewModel vm) => vm.Age,\n    mode: BindingMode.TwoWay,\n    converter: new IntToStringConverter());\n```\n\n---\n\n## Threading\n\nMAUI automatically marshals `PropertyChanged` to the UI thread — you can raise\nit from any thread. **However**, direct `ObservableCollection` mutations\n(Add \u002F Remove) from background threads may crash:\n\n```csharp\n\u002F\u002F ✅ Safe — PropertyChanged is auto-marshalled\nawait Task.Run(() => Title = \"Loaded\");\n\n\u002F\u002F ⚠️ ObservableCollection.Add — dispatch to UI thread\nMainThread.BeginInvokeOnMainThread(() => Items.Add(newItem));\n```\n\n---\n\n## Common Pitfalls\n\n| Mistake | Fix |\n|---------|-----|\n| Missing `x:DataType` — bindings silently fall back to reflection | Add `x:DataType` at page root and every `DataTemplate`; promote `XC0022` (see [Enforce binding warnings as errors](#enforce-binding-warnings-as-errors)) |\n| Forgetting to set `BindingContext` | Set in XAML (`\u003CPage.BindingContext>`) or inject via constructor |\n| Specifying redundant `Mode=OneWay` \u002F `Mode=TwoWay` | Omit `Mode` when using the control's default |\n| ViewModel does not implement `INotifyPropertyChanged` | Use `ObservableObject` from CommunityToolkit.Mvvm or implement manually |\n| Mutating `ObservableCollection` off the UI thread | Wrap mutations in `MainThread.BeginInvokeOnMainThread` |\n| Complex converter chains in hot paths | Pre-compute values in the ViewModel instead |\n| Using `x:DataType=\"x:Object\"` to escape compiled bindings | Restructure bindings; keep compile-time safety |\n| Binding to non-public properties | Binding targets must be `public` properties (fields are ignored) |\n\n---\n\n## References\n\n- [Data binding overview](https:\u002F\u002Flearn.microsoft.com\u002Fdotnet\u002Fmaui\u002Ffundamentals\u002Fdata-binding\u002F)\n- [Compiled bindings](https:\u002F\u002Flearn.microsoft.com\u002Fdotnet\u002Fmaui\u002Ffundamentals\u002Fdata-binding\u002Fcompiled-bindings)\n- [Value converters](https:\u002F\u002Flearn.microsoft.com\u002Fdotnet\u002Fmaui\u002Ffundamentals\u002Fdata-binding\u002Fconverters)\n- [Relative bindings](https:\u002F\u002Flearn.microsoft.com\u002Fdotnet\u002Fmaui\u002Ffundamentals\u002Fdata-binding\u002Frelative-bindings)\n- [Multi-bindings](https:\u002F\u002Flearn.microsoft.com\u002Fdotnet\u002Fmaui\u002Ffundamentals\u002Fdata-binding\u002Fmultibindings)\n- [CommunityToolkit.Mvvm](https:\u002F\u002Flearn.microsoft.com\u002Fdotnet\u002Fcommunitytoolkit\u002Fmvvm\u002F)\n","# .NET MAUI Data Binding\n\nWire UI controls to ViewModel properties with compile-time safety, correct\nchange notification, and minimal overhead. Prefer compiled bindings everywhere\nand treat binding warnings as build errors.\n\n## When to Use\n\n- Adding `x:DataType` compiled bindings to a new or existing page\n- Implementing `INotifyPropertyChanged` or CommunityToolkit `ObservableObject`\n- Creating or consuming `IValueConverter` \u002F `IMultiValueConverter`\n- Choosing the correct `BindingMode` for a control property\n- Setting `BindingContext` in XAML or code-behind\n- Using relative bindings (`Self`, `AncestorType`, `TemplatedParent`)\n- Applying `StringFormat`, `FallbackValue`, or `TargetNullValue`\n- Writing AOT-safe code bindings with `SetBinding` and lambdas (.NET 9+)\n\n## When Not to Use\n\n- **CollectionView layouts \u002F templates** — use the `maui-collectionview` skill\n- **Shell navigation parameters** — use the `maui-shell-navigation` skill\n- **Service registration \u002F DI** — use the `maui-dependency-injection` skill\n- **Property-change-triggered animations** — use built-in [.NET MAUI animation APIs](https:\u002F\u002Flearn.microsoft.com\u002Fdotnet\u002Fmaui\u002Fuser-interface\u002Fanimation\u002Fbasic)\n\n## Inputs\n\n- A .NET MAUI project targeting .NET 8 or later\n- XAML pages or C# code-behind where bindings are declared\n- A ViewModel class (or plan to create one)\n\n## Rules That Change the Answer\n\nApply these to every binding answer — they are the differences between \"it compiles\"\nand \"it actually updates the UI\".\n\n| Situation | Do this | Not this |\n|---|---|---|\n| Deciding where `x:DataType` goes | Put it wherever a binding scope starts — the page\u002Fview root, and **each** `DataTemplate` | Scattering it on arbitrary children that share the parent's `BindingContext` |\n| A binding falls back to reflection (XC0022 \u002F XC0023) | Add the right `x:DataType` for that binding scope; for XC0023 remove the explicit `x:DataType=\"{x:Null}\"` | `x:DataType=\"x:Object\"` to silence it — this disables compile-time checking |\n| A `DataTemplate` inherits `x:DataType` from an outer scope (XC0024) | Give the `DataTemplate` its **own** `x:DataType` | Leaving it to resolve against the wrong type |\n| ViewModel change notification | `ObservableObject` + `[ObservableProperty]`, or implement `INotifyPropertyChanged` | A plain POCO base class — bindings will never update |\n| Bindings show blank | Check `BindingContext` is actually set | Assuming the binding path is wrong |\n| Enforcing compiled bindings | Set `MauiEnableXamlCBindingWithSourceCompilation` to `true`, **then** `\u003CWarningsAsErrors>XC0022;XC0025\u003C\u002FWarningsAsErrors>` | Promoting `XC0025` without the switch if the project uses `Source=` \u002F `RelativeSource` bindings |\n\n**Do not** restructure a ViewModel or add a converter that the user did not ask for\nand that fixes no real defect. Adding `x:DataType` is different: when you are\nalready editing a page's bindings, recommending compiled bindings is in scope.\n\n---\n\n## Compiled Bindings — x:DataType Placement\n\nCompiled bindings are **8–20× faster** than reflection-based bindings and are\nrequired for NativeAOT \u002F trimming. Enable them with `x:DataType`.\n\n### Placement rules\n\nSet `x:DataType` **only where `BindingContext` is set**:\n\n1. **Page \u002F View root** — where you assign `BindingContext`.\n2. **DataTemplate** — which creates a new binding scope.\n\nDo **not** scatter `x:DataType` on arbitrary child elements. Adding\n`x:DataType=\"x:Object\"` on children to escape compiled bindings is an\nanti-pattern — it disables compile-time checking and reintroduces reflection.\n\n```xml\n\u003C!-- ✅ Correct: x:DataType at the page root -->\n\u003CContentPage xmlns:vm=\"clr-namespace:MyApp.ViewModels\"\n             x:DataType=\"vm:MainViewModel\">\n    \u003CStackLayout>\n        \u003CLabel Text=\"{Binding Title}\" \u002F>\n        \u003CSlider Value=\"{Binding Progress}\" \u002F>\n    \u003C\u002FStackLayout>\n\u003C\u002FContentPage>\n\n\u003C!-- ❌ Wrong: x:DataType scattered on children -->\n\u003CContentPage x:DataType=\"vm:MainViewModel\">\n    \u003CStackLayout>\n        \u003CLabel Text=\"{Binding Title}\" \u002F>\n        \u003CSlider x:DataType=\"x:Object\" Value=\"{Binding Progress}\" \u002F>\n    \u003C\u002FStackLayout>\n\u003C\u002FContentPage>\n```\n\n### DataTemplate always needs its own x:DataType\n\n```xml\n\u003CCollectionView ItemsSource=\"{Binding People}\">\n    \u003CCollectionView.ItemTemplate>\n        \u003CDataTemplate x:DataType=\"model:Person\">\n            \u003CLabel Text=\"{Binding FullName}\" \u002F>\n        \u003C\u002FDataTemplate>\n    \u003C\u002FCollectionView.ItemTemplate>\n\u003C\u002FCollectionView>\n```\n\n### Enforce binding warnings as errors\n\n| Warning | Meaning |\n|---------|---------|\n| **XC0022** | Binding used **without `x:DataType` in scope** — not compiled, falls back to reflection |\n| **XC0023** | Binding not compiled because `x:DataType` is **explicitly `null`** |\n| **XC0024** | `x:DataType` came from an **outer scope** — annotate the `DataTemplate` with its own `x:DataType` |\n| **XC0025** | Binding not compiled because it has an explicit **`Source`** — enable `\u003CMauiEnableXamlCBindingWithSourceCompilation>` |\n\n> These four codes are **verified against .NET 10 \u002F .NET 11 MAUI**\n> (`Build.Tasks\u002FBuildException.cs`, `ErrorMessages.resx`). Diagnostic numbering is\n> SDK-band-sensitive — re-check against `BuildException.cs` before relying on it on a\n> newer SDK.\n\nAdd to the `.csproj`:\n\n```xml\n\u003C!-- Compile bindings that use Source= as well; otherwise XC0025 fires on every\n     Source= \u002F RelativeSource binding. As of .NET 10\u002F11 this is on by default\n     only for AOT \u002F full-trim builds. -->\n\u003CMauiEnableXamlCBindingWithSourceCompilation>true\u003C\u002FMauiEnableXamlCBindingWithSourceCompilation>\n\u003CWarningsAsErrors>XC0022;XC0025\u003C\u002FWarningsAsErrors>\n```\n\nIf you promote `XC0025` without enabling that switch, make sure the project has no\n`Source=` \u002F `RelativeSource` bindings — otherwise they will be reported.\n\n---\n\n## Binding Modes\n\nSet `Mode` explicitly **only** when overriding the default. Most properties\nalready have the correct default:\n\n| Mode | Direction | Use case |\n|------|-----------|----------|\n| `OneWay` | Source → Target | Display-only (default for most properties) |\n| `TwoWay` | Source ↔ Target | Editable controls (`Entry.Text`, `Switch.IsToggled`) |\n| `OneWayToSource` | Target → Source | Read user input without pushing back to UI |\n| `OneTime` | Source → Target (once) | Static values; no change-tracking overhead |\n\n```xml\n\u003C!-- ✅ Defaults — omit Mode -->\n\u003CLabel Text=\"{Binding Score}\" \u002F>\n\u003CEntry Text=\"{Binding UserName}\" \u002F>\n\u003CSwitch IsToggled=\"{Binding DarkMode}\" \u002F>\n\n\u003C!-- ✅ Override only when needed -->\n\u003CLabel Text=\"{Binding Title, Mode=OneTime}\" \u002F>\n\u003CEntry Text=\"{Binding SearchQuery, Mode=OneWayToSource}\" \u002F>\n\n\u003C!-- ❌ Redundant — adds noise -->\n\u003CLabel Text=\"{Binding Score, Mode=OneWay}\" \u002F>\n\u003CEntry Text=\"{Binding UserName, Mode=TwoWay}\" \u002F>\n```\n\n---\n\n## BindingContext and Property Paths\n\nEvery `BindableObject` inherits `BindingContext` from its parent unless\nexplicitly set. Property paths support dot notation and indexers:\n\n```xml\n\u003CLabel Text=\"{Binding Address.City}\" \u002F>\n\u003CLabel Text=\"{Binding Items[0].Name}\" \u002F>\n```\n\nSet `BindingContext` in XAML:\n\n```xml\n\u003CContentPage xmlns:vm=\"clr-namespace:MyApp.ViewModels\"\n             x:DataType=\"vm:MainViewModel\">\n    \u003CContentPage.BindingContext>\n        \u003Cvm:MainViewModel \u002F>\n    \u003C\u002FContentPage.BindingContext>\n\u003C\u002FContentPage>\n```\n\nOr in code-behind (preferred with DI):\n\n```csharp\npublic MainPage(MainViewModel vm)\n{\n    InitializeComponent();\n    BindingContext = vm;\n}\n```\n\n---\n\n## INotifyPropertyChanged and ObservableObject\n\n### Manual implementation\n\n```csharp\npublic class MainViewModel : INotifyPropertyChanged\n{\n    public event PropertyChangedEventHandler? PropertyChanged;\n\n    private string _title = string.Empty;\n    public string Title\n    {\n        get => _title;\n        set\n        {\n            if (_title != value)\n            {\n                _title = value;\n                PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(nameof(Title)));\n            }\n        }\n    }\n}\n```\n\n### CommunityToolkit.Mvvm (recommended)\n\n```csharp\nusing CommunityToolkit.Mvvm.ComponentModel;\nusing CommunityToolkit.Mvvm.Input;\n\npublic partial class MainViewModel : ObservableObject\n{\n    [ObservableProperty]\n    private string _title = string.Empty;\n\n    [RelayCommand]\n    private async Task LoadDataAsync() { \u002F* ... *\u002F }\n}\n```\n\nThe source generator creates the `Title` property, `PropertyChanged` raise,\nand `LoadDataCommand` automatically.\n\n---\n\n## Value Converters — IValueConverter\n\nImplement `Convert` (source → target) and `ConvertBack` (target → source):\n\n```csharp\npublic class IntToBoolConverter : IValueConverter\n{\n    public object? Convert(object? value, Type targetType,\n        object? parameter, CultureInfo culture)\n        => value is int i && i != 0;\n\n    public object? ConvertBack(object? value, Type targetType,\n        object? parameter, CultureInfo culture)\n        => value is true ? 1 : 0;\n}\n```\n\nDeclare in XAML resources and consume:\n\n```xml\n\u003CContentPage.Resources>\n    \u003Clocal:IntToBoolConverter x:Key=\"IntToBool\" \u002F>\n\u003C\u002FContentPage.Resources>\n\n\u003CSwitch IsToggled=\"{Binding Count, Converter={StaticResource IntToBool}}\" \u002F>\n```\n\n`ConverterParameter` is always passed as a **string** — parse inside `Convert`:\n\n```xml\n\u003CLabel Text=\"{Binding Score, Converter={StaticResource ThresholdConverter},\n              ConverterParameter=50}\" \u002F>\n```\n\n---\n\n## Multi-Binding\n\nCombine multiple source values with `IMultiValueConverter`:\n\n```xml\n\u003CLabel>\n    \u003CLabel.Text>\n        \u003CMultiBinding Converter=\"{StaticResource FullNameConverter}\">\n            \u003CBinding Path=\"FirstName\" \u002F>\n            \u003CBinding Path=\"LastName\" \u002F>\n        \u003C\u002FMultiBinding>\n    \u003C\u002FLabel.Text>\n\u003C\u002FLabel>\n```\n\n```csharp\npublic class FullNameConverter : IMultiValueConverter\n{\n    public object Convert(object[] values, Type targetType,\n        object parameter, CultureInfo culture)\n    {\n        if (values.Length == 2 && values[0] is string first\n            && values[1] is string last)\n            return $\"{first} {last}\";\n        return string.Empty;\n    }\n\n    public object[] ConvertBack(object value, Type[] targetTypes,\n        object parameter, CultureInfo culture)\n        => throw new NotSupportedException();\n}\n```\n\n---\n\n## Relative Bindings\n\n| Source | Syntax | Use case |\n|--------|--------|----------|\n| Self | `{Binding Source={RelativeSource Self}, Path=WidthRequest}` | Bind to own properties |\n| Ancestor | `{Binding BindingContext.Title, Source={RelativeSource AncestorType={x:Type ContentPage}}}` | Reach parent BindingContext |\n| TemplatedParent | `{Binding Source={RelativeSource TemplatedParent}, Path=Padding}` | Inside ControlTemplate |\n\n```xml\n\u003C!-- Square box: Height = Width -->\n\u003CBoxView WidthRequest=\"100\"\n         HeightRequest=\"{Binding Source={RelativeSource Self}, Path=WidthRequest}\" \u002F>\n```\n\n---\n\n## StringFormat\n\nUse `Binding.StringFormat` for simple display formatting without a converter:\n\n```xml\n\u003CLabel Text=\"{Binding Price, StringFormat='Total: {0:C2}'}\" \u002F>\n\u003CLabel Text=\"{Binding DueDate, StringFormat='{0:MMM dd, yyyy}'}\" \u002F>\n```\n\nWrap the format string in single quotes when it contains commas or braces.\n\n---\n\n## Binding Fallbacks\n\n- **FallbackValue** — used when the binding path cannot be resolved or the\n  converter throws.\n- **TargetNullValue** — used when the bound value is `null`.\n\n```xml\n\u003CLabel Text=\"{Binding MiddleName, TargetNullValue='(none)',\n              FallbackValue='unavailable'}\" \u002F>\n\u003CImage Source=\"{Binding AvatarUrl, TargetNullValue='default_avatar.png'}\" \u002F>\n```\n\n---\n\n## .NET 9+ Code Bindings (AOT-safe)\n\nFully AOT-safe, no reflection:\n\n```csharp\nlabel.SetBinding(Label.TextProperty,\n    static (PersonViewModel vm) => vm.FullName);\n\nentry.SetBinding(Entry.TextProperty,\n    static (PersonViewModel vm) => vm.Age,\n    mode: BindingMode.TwoWay,\n    converter: new IntToStringConverter());\n```\n\n---\n\n## Threading\n\nMAUI automatically marshals `PropertyChanged` to the UI thread — you can raise\nit from any thread. **However**, direct `ObservableCollection` mutations\n(Add \u002F Remove) from background threads may crash:\n\n```csharp\n\u002F\u002F ✅ Safe — PropertyChanged is auto-marshalled\nawait Task.Run(() => Title = \"Loaded\");\n\n\u002F\u002F ⚠️ ObservableCollection.Add — dispatch to UI thread\nMainThread.BeginInvokeOnMainThread(() => Items.Add(newItem));\n```\n\n---\n\n## Common Pitfalls\n\n| Mistake | Fix |\n|---------|-----|\n| Missing `x:DataType` — bindings silently fall back to reflection | Add `x:DataType` at page root and every `DataTemplate`; promote `XC0022` (see [Enforce binding warnings as errors](#enforce-binding-warnings-as-errors)) |\n| Forgetting to set `BindingContext` | Set in XAML (`\u003CPage.BindingContext>`) or inject via constructor |\n| Specifying redundant `Mode=OneWay` \u002F `Mode=TwoWay` | Omit `Mode` when using the control's default |\n| ViewModel does not implement `INotifyPropertyChanged` | Use `ObservableObject` from CommunityToolkit.Mvvm or implement manually |\n| Mutating `ObservableCollection` off the UI thread | Wrap mutations in `MainThread.BeginInvokeOnMainThread` |\n| Complex converter chains in hot paths | Pre-compute values in the ViewModel instead |\n| Using `x:DataType=\"x:Object\"` to escape compiled bindings | Restructure bindings; keep compile-time safety |\n| Binding to non-public properties | Binding targets must be `public` properties (fields are ignored) |\n\n---\n\n## References\n\n- [Data binding overview](https:\u002F\u002Flearn.microsoft.com\u002Fdotnet\u002Fmaui\u002Ffundamentals\u002Fdata-binding\u002F)\n- [Compiled bindings](https:\u002F\u002Flearn.microsoft.com\u002Fdotnet\u002Fmaui\u002Ffundamentals\u002Fdata-binding\u002Fcompiled-bindings)\n- [Value converters](https:\u002F\u002Flearn.microsoft.com\u002Fdotnet\u002Fmaui\u002Ffundamentals\u002Fdata-binding\u002Fconverters)\n- [Relative bindings](https:\u002F\u002Flearn.microsoft.com\u002Fdotnet\u002Fmaui\u002Ffundamentals\u002Fdata-binding\u002Frelative-bindings)\n- [Multi-bindings](https:\u002F\u002Flearn.microsoft.com\u002Fdotnet\u002Fmaui\u002Ffundamentals\u002Fdata-binding\u002Fmultibindings)\n- [CommunityToolkit.Mvvm](https:\u002F\u002Flearn.microsoft.com\u002Fdotnet\u002Fcommunitytoolkit\u002Fmvvm\u002F)\n",{"name":5,"license":14,"description":7},"main","ccab8dffc0ecc173838f51e4c5f0d3b51a704f41","plugins\u002Fopt-in\u002Fimplementation\u002Fcsharp-skills\u002Flibrary\u002Fmaui-data-binding","https:\u002F\u002Fgithub.com\u002Fdeadmade\u002Fdead-agent-skills","https:\u002F\u002Fgithub.com\u002Fdeadmade","https:\u002F\u002Fdeadmade.github.io\u002F","Blood, an Ocean of blood","2026-11-14 02:03:31",{"source":8,"skillName":5,"commands":32,"prompt":42,"zipAvailable":43},[33,36,39],{"tool":34,"command":35},"npx","npx skills add deadmade\u002Fdead-agent-skills --skill maui-data-binding",{"tool":37,"command":38},"bunx","bunx skills add deadmade\u002Fdead-agent-skills --skill maui-data-binding",{"tool":40,"command":41},"pnpm","pnpm dlx skills add deadmade\u002Fdead-agent-skills --skill maui-data-binding","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002Fdeadmade\u002Fdead-agent-skills\u002Fblob\u002Fmain\u002Fplugins\u002Fopt-in\u002Fimplementation\u002Fcsharp-skills\u002Flibrary\u002Fmaui-data-binding\u002FSKILL.md",true,[45],{"path":46,"resourceType":47,"resourceTypeDesc":48,"sizeBytes":49,"sourceHtmlUrl":50},"references\u002Fdata-binding-api.md","REFERENCE","参考文档",4130,"https:\u002F\u002Fgithub.com\u002Fdeadmade\u002Fdead-agent-skills\u002Fblob\u002Fmain\u002Fplugins\u002Fopt-in\u002Fimplementation\u002Fcsharp-skills\u002Flibrary\u002Fmaui-data-binding\u002Freferences\u002Fdata-binding-api.md",[52,59,68,76,83,90],{"skillNo":53,"name":54,"nameZh":6,"description":55,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":9,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":56,"categories":57,"keywords":58,"publishedAt":18},"01M7CVRBFTXSTTQ7F5P6PJEFYA","rust-best-practices","Guide for writing idiomatic Rust code based on Apollo GraphQL's best practices handbook. Use this skill when: (1) writing new Rust code or functions, (2) reviewing or refactoring existing Rust code, (3) deciding between borrowing vs cloning or ownership patterns, (4) implementing error handling with Result types, (5) optimizing Rust code for performance, (6) writing tests or documentation for Rust projects.","https:\u002F\u002Fgithub.com\u002Fdeadmade\u002Fdead-agent-skills\u002Fblob\u002Fmain\u002Fplugins\u002Fopt-in\u002Fimplementation\u002Frust-skills\u002Fskills\u002Frust-best-practices\u002FSKILL.md",[],[],{"skillNo":60,"name":61,"nameZh":6,"description":62,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":9,"repositoryNo":12,"starsCount":13,"licenseSpdxId":63,"licenseFileUrl":64,"sourceHtmlUrl":65,"categories":66,"keywords":67,"publishedAt":18},"01M7CVR0W7B8EGTNPSPA7FPC4Z","postgres-database-migration","Use this skill for planning, testing, and safely executing PostgreSQL schema migrations — especially when working with production data or shared databases.\n\n**Trigger when user asks to:**\n- Test a schema migration before applying it to production\n- Add, remove, or rename columns safely on a live table\n- Change a column's data type without downtime\n- Add or drop indexes, constraints, or foreign keys on large tables\n- Understand which ALTER TABLE operations lock the table\n- Roll back a failed migration\n- Plan a zero-downtime migration strategy\n- Fork a database to test a migration safely\n\nCovers: lock-level reference for every common DDL operation, safe migration patterns, fork-based testing, zero-downtime column changes, index creation, constraint addition, backfill strategies, pre\u002Fpost-migration validation, and rollback planning.","Apache-2.0","https:\u002F\u002Fgithub.com\u002Fdeadmade\u002Fdead-agent-skills\u002Fblob\u002Fmain\u002Fplugins\u002Fopt-in\u002Fimplementation\u002Fpostgres\u002Fskills\u002Fpostgres-database-migration\u002FLICENSE","https:\u002F\u002Fgithub.com\u002Fdeadmade\u002Fdead-agent-skills\u002Fblob\u002Fmain\u002Fplugins\u002Fopt-in\u002Fimplementation\u002Fpostgres\u002Fskills\u002Fpostgres-database-migration\u002FSKILL.md",[],[],{"skillNo":69,"name":70,"nameZh":6,"description":71,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":9,"repositoryNo":12,"starsCount":13,"licenseSpdxId":63,"licenseFileUrl":72,"sourceHtmlUrl":73,"categories":74,"keywords":75,"publishedAt":18},"01M7CVQWK20ASAZN5VETZC8J99","postgres-best-practices","Best practices and guidelines for working with Postgres. Covers schema design, indexing strategies, query optimization, migrations, and common pitfalls. Use when writing SQL, designing database schemas, optimizing queries, or setting up a Postgres database.","https:\u002F\u002Fgithub.com\u002Fdeadmade\u002Fdead-agent-skills\u002Fblob\u002Fmain\u002Fplugins\u002Fopt-in\u002Fimplementation\u002Fpostgres\u002Fskills\u002Fpostgres-best-practices\u002FLICENSE","https:\u002F\u002Fgithub.com\u002Fdeadmade\u002Fdead-agent-skills\u002Fblob\u002Fmain\u002Fplugins\u002Fopt-in\u002Fimplementation\u002Fpostgres\u002Fskills\u002Fpostgres-best-practices\u002FSKILL.md",[],[],{"skillNo":77,"name":78,"nameZh":6,"description":79,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":9,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":80,"categories":81,"keywords":82,"publishedAt":18},"01M7CVQ5CY7AQHY7A2Y99RE6A7","writing-mstest-tests","ALWAYS USE when asked to fix, rewrite, update, improve, modernize, show corrected code for, or explain existing MSTest tests or MSTest-specific configuration. Use for \"review\" when corrected code or edits are wanted, even for one pasted assertion or passing tests with bad failure output. Covers expected\u002Factual labels; generic Boolean, collection, string, numeric, null, identity, exception, hard-cast, and object[] checks; TestContext\u002Flifecycle; timeout\u002Fcancellation; OS\u002FCI conditions, retry, cleanup, parallelization, MSTest.Sdk project setup, and MSTESTxxxx. Honor the installed MSTest version. DO NOT USE to design new test cases (code-testing), perform report-only audits, create project files rather than explain MSTest setup, run tests, migrate frameworks, or handle non-MSTest\u002Fnon-.NET code.","https:\u002F\u002Fgithub.com\u002Fdeadmade\u002Fdead-agent-skills\u002Fblob\u002Fmain\u002Fplugins\u002Fopt-in\u002Fimplementation\u002Fcsharp-skills\u002Flibrary\u002Fwriting-mstest-tests\u002FSKILL.md",[],[],{"skillNo":84,"name":85,"nameZh":6,"description":86,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":9,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":87,"categories":88,"keywords":89,"publishedAt":18},"01M7CVPWJZ63GB0810F0SCGZ1K","winforms-expert","Create, modify, debug, or review Windows Forms applications only when the request contains a concrete Windows Forms marker. USE FOR: WinForms, Windows Forms, System.Windows.Forms, WinForms Form or UserControl designer files (*.Designer.cs or *.Designer.vb), Visual Studio WinForms Designer, TableLayoutPanel, BindingSource, DataGridView, Control.InvokeAsync, component-tray ownership, or custom control serialization. DO NOT USE FOR: WPF or WPF XAML, including Window.InputBindings, KeyBinding, commands, or DataContext; .NET MAUI; Avalonia; or any request where none of the listed Windows Forms markers is present.","https:\u002F\u002Fgithub.com\u002Fdeadmade\u002Fdead-agent-skills\u002Fblob\u002Fmain\u002Fplugins\u002Fopt-in\u002Fimplementation\u002Fcsharp-skills\u002Flibrary\u002Fwinforms-expert\u002FSKILL.md",[],[],{"skillNo":91,"name":92,"nameZh":6,"description":93,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":9,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":94,"categories":95,"keywords":96,"publishedAt":18},"01M7CVPR0QFZ1HMJ6GZRBQAQ7W","vectorization","Design, implement, optimize, and review SIMD code in .NET. USE FOR: vectorizing scalar loops with TensorPrimitives, Vector64\u002F128\u002F256\u002F512, or platform hardware intrinsics; reviewing existing SIMD code, including the generic Vector type, for contract equivalence, tail handling, memory safety, portability, fallbacks, and measured performance. DO NOT USE FOR: performance work unrelated to SIMD or vectorization.","https:\u002F\u002Fgithub.com\u002Fdeadmade\u002Fdead-agent-skills\u002Fblob\u002Fmain\u002Fplugins\u002Fopt-in\u002Fimplementation\u002Fcsharp-skills\u002Flibrary\u002Fvectorization\u002FSKILL.md",[],[]]