maui-data-binding
帮助 MAUI 开发者启用编译时安全的绑定并修复通知/绑定问题,提高稳定性与可维护性。
提供 .NET MAUI 中 XAML/C# 数据绑定、INotify 与 MVVM 最佳实践的详细指导。
解决 .NET MAUI 下 XAML/C# 的数据绑定痛点,让 UI 与 ViewModel 的属性绑定既安全又高效。常用场景包括加 x:DataType 编译绑定、实现 INotifyPropertyChanged/ObservableObject、写 IValueConverter、选 binding mode 或做相对绑定。特别强调编译时校验和把绑定警告当错误,能显著减少运行时丢失更新的问题。
▸ 展开 SKILL.md 英文原文
Guidance for .NET MAUI XAML and C# data bindings — compiled bindings, INotifyPropertyChanged / 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 / IMultiValueConverter, choosing binding modes, configuring BindingContext, relative bindings, binding fallbacks, StringFormat, code-behind SetBinding with lambdas, and enforcing XC0022/XC0025 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).
帮我安装这个 skill:https://raw.githubusercontent.com/dotnet/skills/main/plugins/dotnet-maui/skills/maui-data-binding/SKILL.mdcurl -fsSL "https://raw.githubusercontent.com/dotnet/skills/main/plugins/dotnet-maui/skills/maui-data-binding/SKILL.md"# .NET MAUI Data Binding Wire UI controls to ViewModel properties with compile-time safety, correct change notification, and minimal overhead. Prefer compiled bindings everywhere and treat binding warnings as build errors. ## When to Use - Adding `x:DataType` compiled bindings to a new or existing page - Implementing `INotifyPropertyChanged` or CommunityToolkit `ObservableObject` - Creating or consuming `IValueConverter` / `IMultiValueConverter` - Choosing the correct `BindingMode` for a control property - Setting `BindingContext` in XAML or code-behind - Using relative bindings (`Self`, `AncestorType`, `TemplatedParent`) - Applying `StringFormat`, `FallbackValue`, or `TargetNullValue` -