- 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:

推薦閱讀
- Android應(yīng)用程序開(kāi)發(fā)與典型案例
- Arduino by Example
- AWS Serverless架構(gòu):使用AWS從傳統(tǒng)部署方式向Serverless架構(gòu)遷移
- C和C++安全編碼(原書(shū)第2版)
- Ray分布式機(jī)器學(xué)習(xí):利用Ray進(jìn)行大模型的數(shù)據(jù)處理、訓(xùn)練、推理和部署
- Python GUI Programming Cookbook
- Python高效開(kāi)發(fā)實(shí)戰(zhàn):Django、Tornado、Flask、Twisted(第2版)
- Python自然語(yǔ)言處理(微課版)
- Oracle BAM 11gR1 Handbook
- Mastering Python Networking
- Learning DHTMLX Suite UI
- ANSYS Fluent 二次開(kāi)發(fā)指南
- 從零學(xué)Java設(shè)計(jì)模式
- 從零開(kāi)始:C語(yǔ)言快速入門(mén)教程
- Mastering Bootstrap 4