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

推薦閱讀
- Apache ZooKeeper Essentials
- INSTANT OpenCV Starter
- 控糖控脂健康餐
- ASP.NET動態網頁設計教程(第三版)
- Python神經網絡項目實戰
- Mastering Swift 2
- Windows Presentation Foundation Development Cookbook
- Reactive Programming With Java 9
- Bootstrap 4 Cookbook
- R用戶Python學習指南:數據科學方法
- C++反匯編與逆向分析技術揭秘(第2版)
- Learning Nessus for Penetration Testing
- PhoneGap 4 Mobile Application Development Cookbook
- 安卓工程師教你玩轉Android
- The Python Apprentice