- Mastering Visual Studio 2017
- Kunal Chowdhury
- 142字
- 2021-07-15 17:26:43
The code behind file of an XAML page
When an XAML is markup compiled, it has an associated code behind class file. The code behind is a partial class and derives from the same class, which is the root of the XAML page element:
public partial class MainWindow : Window { public MainWindow() { InitializeComponent(); } }
The constructor of the class gives a call to the InitializeComponent method available in another partial class implementation, which resides in a .g.i.cs file. For example, if your XAML page name is MainWindow.xaml, its associated code behind is MainWindow.xaml.cs and the core partial implementation is in an autogenerated file named MainWindow.g.i.cs. The .g.i.cs file can be located in the obj folder under the project. It loads your XAML page and defines the UI elements placed in the designer.
Here's how the InitializeComponent() method looks like:

推薦閱讀
- 自制編譯器
- Vue.js快跑:構建觸手可及的高性能Web應用
- 算法大爆炸:面試通關步步為營
- Java程序設計與計算思維
- 零基礎學Java(第4版)
- Big Data Analytics
- H5頁面設計:Mugeda版(微課版)
- Getting Started with Greenplum for Big Data Analytics
- Linux C編程:一站式學習
- GameMaker Essentials
- HTML+CSS+JavaScript編程入門指南(全2冊)
- INSTANT Apache ServiceMix How-to
- C Primer Plus(第6版)中文版【最新修訂版】
- C++從零開始學(視頻教學版)(第2版)
- Spring MVC Blueprints