Summary of WPF Application entry functions (main function) in

Source: Internet
Author: User

The portal function for a Windows Forms application is in the Program.cs file, but where is the WPF application Portal function when the WPF application does not have this file? Add a portal function manually, build the project, and make an error:

The original WPF Application entry function is in the Objreleaseapp.g.cs file:

Program code

The code is as follows Copy Code

Public partial class App:System.Windows.Application {

[System.Diagnostics.DebuggerNonUserCodeAttribute ()]
[System.CodeDom.Compiler.GeneratedCodeAttribute ("PresentationBuildTasks", "")]
public void InitializeComponent () {

#line 4 ". \.. \app.xaml "
This. StartupUri = new System.Uri ("MainWindow.xaml", System.UriKind.Relative);

#line default
#line hidden

Application Entry point.
[System.STAThreadAttribute ()]
[System.Diagnostics.DebuggerNonUserCodeAttribute ()]
[System.CodeDom.Compiler.GeneratedCodeAttribute ("PresentationBuildTasks", "")]
public static void Main () { App = new ();
App. InitializeComponent ();
App. Run ();

As you can see from the code, the StartupUri in the InitializeComponent method is used to specify the main form of the WPF application, and if you need to modify the main form is this a change here? No way! App.g.cs Note:

Reference content
This code is generated by the tool.
Run-time Version: 4.0.30319.18052
Changes to this file may cause incorrect behavior, and if
The code is regenerated, and these changes will be lost.

The WPF Application main form should be modified in the App.xaml file:

  code is as follows copy code
<application x:class=" "
              xmlns= " Presentation "
             xmlns:x=" http:// "
              startupuri= "MainWindow.xaml"
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.