Skip to main content

XAML Compilation

Using the XAML compiler to increase the performance of a Xamarin.Forms app

XAML can be optionally compiled directly into intermediate language (IL) with the XAML compiler (XAMLC).
XAMLC 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.


XAMLC is disabled by default to ensure backwards compatibility. It can be enabled at both the assembly and class level by adding the XamlCompilation attribute.

The following code example demonstrates enabling XAMLC at the assembly level:

It helps to reduce the file size of the final assembly by no longer including .xaml files.

The following code example demonstrates enabling XAMLC at the assembly level:
using Xamarin.Forms.Xaml;
[assembly: XamlCompilation(XamlCompilationOptions.Compile)]You can also enable XAMLC at the class level


Comments

Popular posts from this blog

Error CS0234 The type or namespace name 'ApplicationInsights' does not exist in the namespace 'Microsoft' (are you missing an assembly reference?)

Error CS0234 The type or namespace name 'ApplicationInsights' does not exist in the namespace 'Microsoft' (are you missing an assembly reference?)
To fix this issue run the following command in the Package Manager Console 
Install-Package Microsoft.ApplicationInsights.WindowsApps

WPF - Checking Cap Lock Status in WPF

Checking Cap Lock status will be useful in Logon page where we can provide warning to user <Caps Lock is on. Having Caps Lock on may cause you to enter password incorrectly.>

Following sample uses the Control class that is a standard class within the System.Windows.Forms namespace. The DLL containing this namespace is automatically included in Windows Forms applications. The class includes a method named IsKeyLocked, which allows you to determine whether keys such as Caps Lock are switched on or off. To check the status of the Caps Lock key, you can use the method in the following manner:

Example:
privatevoid KeyDownEventHanlder(object sender, KeyEventArgs e)
{
if (Console.CapsLock == true)
{
lblError.Foreground = Brushes.Red;
lblError.Content = "Caps Lock is on.";// Having Caps Lock on may cause you to enter password incorrectly.";

}

else

{
if (lblError.Foreground == Brushes.Red)lblError.Foreground = Brushes.Transparent;
}

}