According to http://stuff.seans.com/2008/07/11/hello-wpf-world-part-1/, it is generated automatically.
Can I prevent to create it so that I can create my own version ?
According to http://stuff.seans.com/2008/07/11/hello-wpf-world-part-1/, it is generated automatically.
Can I prevent to create it so that I can create my own version ?
In App.g.i.cs
contains a function Main()
is a standard entry point for an application and it is created automatically. If you want, you can provide your own class that implements Main()
Link
:
We can write in some other classes like Window1.xaml.cs. Then how the system identifies which
Main()
should get called. That too simple. Go to project properties, select application tab, then change the start up object to Window1.cs.
Here
are the three approaches to add your own implementation of App.xaml
:
Approach 1
You can delete the existing App.xaml
and App.xaml.cs
and add a new class file and maybe call it App.cs. In this you can define the App class and write your own Main method as below.
Approach 2
You will run into issues with Approach 1 if you are adding resources and resource dictionaries to your App.xaml. Since the App.xaml is no longer present you will have to write code in your App.cs itself to manage the resources and the merged dictionaries. However this can be more easily handled by modifying the .csproj file and marking App.xaml as Page instead of ApplicationDefinition.
Approach 3
If you have resources and hence want to have App.xaml, but don't like to tamper with .csproj file, then you can include another class in your project that defines the Main method as below.
Also, you can see this link: