How effective is XAML parsing in WinRT / Win8?

When creating UserControls, it looks like XAML is parsed every time the control is initialized.

For example, when I create a UserControl, an automatically generated code is generated to initialize the component, which looks like this:

public void InitializeComponent() { if (_contentLoaded) return; _contentLoaded = true; global::Windows.UI.Xaml.Application.LoadComponent(this, new global::System.Uri("ms-appx:///Views/MyView.xaml"), global::Windows.UI.Xaml.Controls.Primitives.ComponentResourceLocation.Application); } 

It was in Silverlight.

Creating a control one or two doesn't really matter, but if I have a large visual tree in each UserControl with visual states and bindings, and I create it many times for the application life cycle, it would be wise to create visual controls using C # to increase productivity.

So my question is:

Does the parser / framework parse the "XAML file" and not repeat it again on subsequent calls? That is, it creates a binary XAML representation, so it doesn’t need to read the text again?

+4
source share
2 answers

As far as I understand, XAML is compiled in binary form as a resource in your application. The runtime should not parse the text of the .xaml file, since it does not need to parse your .cs code files.

The performance of creating instances of classes declared using XAML should be the same as creating it in code.

0
source

Windows 8.1 xaml finally added the binary XAML format :)

XAML binary format: the final signed appx will no longer contain text markup, as it will be converted to binary.

0
source

Source: https://habr.com/ru/post/1447378/


All Articles