I thought I had read before that this was only needed for the App class but now when I go to the sample tabbed application that is part of the Xamarin Form official templates I see it added above every class.
Can someone please confirm. Just the one class or every class when it is added?
XAML can be optionally compiled directly into intermediate language (IL) with the XAML compiler (XAMLC). XAML compilation offers a number of a benefits: It performs compile-time checking of XAML, notifying the user of any errors. It removes some of the load and instantiation time for XAML elements.
If you want to enable compiled XAML through out your application just set [assembly: XamlCompilation (XamlCompilationOptions. Compile)] just above your namespace in App. cs file as below: [assembly: XamlCompilation (XamlCompilationOptions.
Xamarin. Forms is an open source cross-platform framework from Microsoft for building iOS, Android, & Windows apps with . NET from a single shared codebase. Use Xamarin. Forms built in pages, layouts, and controls to build and design mobile apps from a single API that is highly extensible.
Both are acceptable.
If you want to enable compiled XAML through out your application just set [assembly: XamlCompilation (XamlCompilationOptions.Compile)] just above your namespace in App.cs file as below:
[assembly: XamlCompilation (XamlCompilationOptions.Compile)]
namespace App
{
....
}
If you want to enable per file then set it as below at class level.
[XamlCompilation (XamlCompilationOptions.Compile)]
public class TestPage : ContentPage
{
....
}
Read out more on this at:
https://devblogs.microsoft.com/xamarin/optimizing-xamarin-forms-apps-for-maximum-performance/
No, you can add an assembly level attribute just once for it to include all your XAML files:
[assembly: XamlCompilation (XamlCompilationOptions.Compile)]
re: https://docs.microsoft.com/en-us/xamarin/xamarin-forms/xaml/xamlc
using Xamarin.Forms.Xaml;
...
[assembly: XamlCompilation (XamlCompilationOptions.Compile)]
namespace SomeApp
{
...
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With