# XAML Performance / Tối Ưu XAML Hướng dẫn chi tiết về Compiled Bindings, layout optimization và XAML best practices. ## Core Principles / Nguyên Tắc Cốt Lõi 1. **Compiled Bindings**: Luôn sử dụng `x:DataType` để binding tại compile-time 2. **Flat Layouts**: Tránh nested layouts, ưu tiên Grid 3. **Virtualization**: Sử dụng CollectionView cho danh sách lớn --- ## Compiled Bindings (BẮT BUỘC) ### Why Compiled Bindings? | Aspect | Reflection Binding | Compiled Binding | |--------|-------------------|------------------| | Performance | Slow (runtime lookup) | Fast (compile-time) | | Error Detection | Runtime exceptions | Compile-time errors | | NativeAOT | May not work | Full support | | Intellisense | No | Yes | ### Basic Pattern ```xml ``` ```xml ``` ### Nested DataType Changes ```xml ``` ### Binding to Parent ViewModel from ItemTemplate ```xml