1

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 ?

0

1 Answer 1

3

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:

Living Without App.xaml and still being able to use Blend

1
  • Thank you I will think about your suggestion (it's rather for Windows Phone in fact).
    – user310291
    Commented Apr 13, 2014 at 10:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.