Windows Presentation Foundation · WinFX

Early notice of a change to WPF templates: "MyApp.xaml" to "App.xaml"

Rob Relyea · Original date not recorded · Restored archive post · Edited by Muhd Radhi Wahab
Restored from the windows-now.com archive. This post was originally published by Rob Relyea on windows-now.com. The original publication date was not recorded in the archive capture. It is reproduced faithfully for its historical and reference value, with the original author credited. If you are the author and would like this amended or removed, contact us.

Just a quick note to book authors, users, and anybody else who cares.

I'm communicating early because...well, why wait?

Microsoft Tools and MyApp.xaml
The VS "Orcas" team and Expression Interactive Designer team plan to change a few things about the default files created when you create a new WPF project.  You'll likely see the change in VS next CTP...EID will come the release after that.

Today's Model
Today, VS "Orcas" creates a MyApp.xaml file with the following root element:

<Application x:Class="ProjectName.MyApp" ...>

Today, EID ("Sparkle") creates an Application.xaml file with the following root element:

<Application x:Class="ProjectName.MainApplication" ... >

Next CTP's model
Those teams have decided to move to a consistent model.  The file will be called App.xaml and will look like this:

<Application x:Class="ProjectName.App" ... >
</Application>

What should you do?

Tool authors - you likely want to be consistent with this change.
Book authors - you probably want to update your examples.
Users - you can rename your files and x:Class attribute value if you like...although there is no need.

Manual steps to Change an existing project (if you want to)

To change your project in EID:

1) right click on Application.xaml, rename to App.xaml
2) right click on Application.xaml.cs or Application.xaml.vb, rename to App.xaml.cs or App.xaml.vb
3) in App.xaml, change x:Class="UntitledProject1.MainApplication" to x:Class="UntitledProject1.App"
4) if C# project, in App.xaml.cs:
    change from:

public partial class MainApplication: System.Windows.Application

   change to:

public partial class App: System.Windows.Application

5) if VB project, in App.xaml.vb:
    change from:

Partial Public Class MainApplication
    Inherits System.Windows.Application

   change to:

Partial Public Class App
    Inherits System.Windows.Application

To change your project in VS "Orcas":

1) right click on MyApp.xaml, rename to App.xaml
2) right click on Application.xaml.cs or Application.xaml.vb, rename to App.xaml.cs or App.xaml.vb
3) in App.xaml, change x:Class="ProjectName.MyApp" to x:Class="ProjectName.App"
4) if C# project, in App.xaml.cs:
    change from:

public partial class MyApp : Application

   change to:

public partial class App : Application

5) if VB project, in App.xaml.vb:
    change from:

Partial Public Class MyApp
    Inherits Application

   change to:

Partial Public Class App
    Inherits Application

Please let us know if you have questions/issues.

Frequently asked

Why is MyApp.xaml changing to App.xaml?

The VS "Orcas" team and the Expression Interactive Designer team decided to move to a consistent model for the default files created for a new WPF project. The application file will be called App.xaml with the root element <Application x:Class="ProjectName.App" ...>.

Do I need to rename MyApp.xaml in my existing projects?

No. Users can rename their files and x:Class attribute value if they like, although there is no need. Tool authors likely want to be consistent with the change, and book authors probably want to update their examples.