官术网_书友最值得收藏!

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

主站蜘蛛池模板: 枣阳市| 扶风县| 双牌县| 遵义县| 北流市| 徐汇区| 淳化县| 嘉祥县| 抚松县| 镇宁| 江达县| 诏安县| 伽师县| 竹山县| 正定县| 开远市| 阿拉善右旗| 南宫市| 济宁市| 庆云县| 长武县| 新宁县| 综艺| 连城县| 远安县| 泌阳县| 台山市| 宜宾市| 林芝县| 麻江县| 阜康市| 中宁县| 怀来县| 张北县| 台北市| 古浪县| 乐昌市| 京山县| 高密市| 黑山县| 四川省|