[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M7D1V0GRVZAS0B3XBGVMEF3B":3,"skill-same:01M7D1V0GRVZAS0B3XBGVMEF3B":50},{"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":18,"publishedAt":19,"linkOnly":20,"markdownContent":21,"markdownBody":22,"frontMatter":23,"refName":24,"commitSha":25,"skillDirectory":26,"forksCount":14,"repositoryHtmlUrl":27,"repositoryHomepageUrl":6,"ownerHtmlUrl":28,"ownerBlogUrl":6,"ownerDescription":6,"updatedAt":29,"install":30,"resources":43},"01M7D1V0GRVZAS0B3XBGVMEF3B","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).","itsmejay18\u002FAI-Skills-for-My-Development-Stack","itsmejay18","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F167779943?v=4","01M7CZRFC6DDZA5V2CX8WDSZED","Jay Jemino Ababon ","01M7CZRFCVRNW1SFHSQXEJ3CQN",0,"MIT","https:\u002F\u002Fgithub.com\u002Fitsmejay18\u002FAI-Skills-for-My-Development-Stack\u002Fblob\u002Fmain\u002F10-Mobile-Development\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":15,"description":7},"main","30954af1dcd1a74b63f05deb2e2c41e5ecae4a82","10-Mobile-Development\u002Fmaui-data-binding","https:\u002F\u002Fgithub.com\u002Fitsmejay18\u002FAI-Skills-for-My-Development-Stack","https:\u002F\u002Fgithub.com\u002Fitsmejay18","2026-09-18 16:06:36",{"source":8,"skillName":5,"commands":31,"prompt":41,"zipAvailable":42},[32,35,38],{"tool":33,"command":34},"npx","npx skills add itsmejay18\u002FAI-Skills-for-My-Development-Stack --skill maui-data-binding",{"tool":36,"command":37},"bunx","bunx skills add itsmejay18\u002FAI-Skills-for-My-Development-Stack --skill maui-data-binding",{"tool":39,"command":40},"pnpm","pnpm dlx skills add itsmejay18\u002FAI-Skills-for-My-Development-Stack --skill maui-data-binding","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002Fitsmejay18\u002FAI-Skills-for-My-Development-Stack\u002Fblob\u002Fmain\u002F10-Mobile-Development\u002Fmaui-data-binding\u002FSKILL.md",true,[44],{"path":45,"resourceType":46,"resourceTypeDesc":47,"sizeBytes":48,"sourceHtmlUrl":49},"references\u002Fdata-binding-api.md","REFERENCE","参考文档",4130,"https:\u002F\u002Fgithub.com\u002Fitsmejay18\u002FAI-Skills-for-My-Development-Stack\u002Fblob\u002Fmain\u002F10-Mobile-Development\u002Fmaui-data-binding\u002Freferences\u002Fdata-binding-api.md",[51,58,65,72,79,86],{"skillNo":52,"name":53,"nameZh":6,"description":54,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":55,"categories":56,"keywords":57,"publishedAt":19},"01M7D2RKBHPZ3E1RNN5DWHT550","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 Vector\u003CT>, 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\u002Fitsmejay18\u002FAI-Skills-for-My-Development-Stack\u002Fblob\u002Fmain\u002F20-Performance-Optimization\u002Fvectorization\u002FSKILL.md",[],[],{"skillNo":59,"name":60,"nameZh":6,"description":61,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":62,"categories":63,"keywords":64,"publishedAt":19},"01M7D2RDJ7RN3QK8GJR0QTER1D","resolve-project-references","Guide for interpreting ResolveProjectReferences time in MSBuild performance summaries. Activate when ResolveProjectReferences appears as the most expensive target and developers are trying to optimize it directly. Explains that the reported time includes wait time for dependent project builds and is misleading. Guides users to focus on task self-time instead. Do not activate for general build performance -- use build-perf-diagnostics instead.","https:\u002F\u002Fgithub.com\u002Fitsmejay18\u002FAI-Skills-for-My-Development-Stack\u002Fblob\u002Fmain\u002F20-Performance-Optimization\u002Fresolve-project-references\u002FSKILL.md",[],[],{"skillNo":66,"name":67,"nameZh":6,"description":68,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":69,"categories":70,"keywords":71,"publishedAt":19},"01M7D2R1H2GTNZYHG9YRX3JDQW","optimizing-ef-core-queries","Optimize and improve the performance of slow Entity Framework Core (EF Core) queries: make them generate less SQL, make fewer database round-trips, and return results faster. Use whenever an EF Core or DbContext query or data-access path is slow or should be made faster — whether or not EF Core owns the database schema. For EF Core, not Dapper or raw ADO.NET.","https:\u002F\u002Fgithub.com\u002Fitsmejay18\u002FAI-Skills-for-My-Development-Stack\u002Fblob\u002Fmain\u002F20-Performance-Optimization\u002Foptimizing-ef-core-queries\u002FSKILL.md",[],[],{"skillNo":73,"name":74,"nameZh":6,"description":75,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":76,"categories":77,"keywords":78,"publishedAt":19},"01M7D2QREG04W1YT0NEBHEW5C9","microbenchmarking","Activate this skill when BenchmarkDotNet (BDN) is involved in the task — creating, running, configuring, or reviewing BDN benchmarks. Also activate when microbenchmarking .NET code would be useful and BenchmarkDotNet is the likely tool. Consider activating when answering a .NET performance question requires measurement and BenchmarkDotNet may be needed. Covers microbenchmark design, BDN configuration and project setup, how to run BDN microbenchmarks efficiently and effectively, and using BDN for side-by-side performance comparisons. Do NOT use for profiling\u002Ftracing .NET code (dotnet-trace, PerfView), production telemetry, or load\u002Fstress testing (Crank, k6).","https:\u002F\u002Fgithub.com\u002Fitsmejay18\u002FAI-Skills-for-My-Development-Stack\u002Fblob\u002Fmain\u002F20-Performance-Optimization\u002Fmicrobenchmarking\u002FSKILL.md",[],[],{"skillNo":80,"name":81,"nameZh":6,"description":82,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":83,"categories":84,"keywords":85,"publishedAt":19},"01M7D2QGE175XWPZVACVH2868Z","incremental-build","Guide for optimizing MSBuild incremental builds. USE FOR: builds slower than expected on subsequent runs, 'nothing changed but it rebuilds anyway', diagnosing why targets re-execute unnecessarily, fixing broken no-op builds. Covers 8 common causes: missing Inputs\u002FOutputs on custom targets, volatile properties in output paths (timestamps\u002FGUIDs), file writes outside tracked Outputs, missing FileWrites registration, glob changes, Visual Studio Fast Up-to-Date Check (FUTDC) issues. Key diagnostic: look for 'Building target completely' vs 'Skipping target' in binlog. DO NOT USE FOR: first-time build slowness (use build-perf-baseline), parallelism issues (use build-parallelism), evaluation-phase slowness (use eval-performance), non-MSBuild build systems.","https:\u002F\u002Fgithub.com\u002Fitsmejay18\u002FAI-Skills-for-My-Development-Stack\u002Fblob\u002Fmain\u002F20-Performance-Optimization\u002Fincremental-build\u002FSKILL.md",[],[],{"skillNo":87,"name":88,"nameZh":6,"description":89,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":90,"categories":91,"keywords":92,"publishedAt":19},"01M7D2Q1DQTC6K49R73WQTTPSB","eval-performance","Guide for diagnosing and improving MSBuild project evaluation performance. USE FOR: builds slow before any compilation starts, high evaluation time in binlog analysis, expensive glob patterns walking large directories (node_modules, .git, bin\u002Fobj), deep import chains (>20 levels), preprocessed output >10K lines indicating heavy evaluation, property functions with file I\u002FO ($([System.IO.File]::ReadAllText(...))), multiple evaluations per project. Covers the 5 MSBuild evaluation phases, glob optimization via DefaultItemExcludes, import chain analysis with \u002Fpp preprocessing. DO NOT USE FOR: compilation-time slowness (use build-perf-diagnostics), incremental build issues (use incremental-build), non-MSBuild build systems.","https:\u002F\u002Fgithub.com\u002Fitsmejay18\u002FAI-Skills-for-My-Development-Stack\u002Fblob\u002Fmain\u002F20-Performance-Optimization\u002Feval-performance\u002FSKILL.md",[],[]]