Generated Source Code
Some procedural code does get generated in the XAML compilation process (if you use x:Class
), but it’s just some “glue code” similar to what had to be written to load and parse a loose XAML file at runtime. Such files are given a suffix such as .g.cs
and .g.i.cs
(or .g.vb
and .g.i.vb
), where the g
stands for generated and the i
stands for IntelliSense.
Each generated source file contains a partial class definition for the class specified with x:Class
on the root object element. This partial class contains a field (private by default but configurable with x:FieldModifier
) for every named element in the XAML file, using the element name as the field name. It also contains an InitializeComponent
method that does the grunt work ...
Get XAML Unleashed now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.