When coding WinForms applications, I always start with an empty project, then add an Application Class, Forms, etc... In doing so, I can build up the application from scratch, keeping it clean, without all the "fluff" of the Standard WinForms projects, which add Forms, etc... for you.
I want to do the same with WPF. I've created my application class, made a Window class and I can run the application just fine, but there is no XAML associated with the window because I'm just declaring it as a derived class from Window.
My question is, can WPF -Windows be added to a project like WinForms -Forms such that the XAML is also added and the designer can be used to layout the controls etc...? Or do I have to use the canned "WPF Project" and go from there?
Apparently it's not possible to create an Empty Project and add XAML backed Windows. If anyone knows why, I would appreciate an explanation. (You can, however, create programmatically generated windows, or if you want your own startup object in a default WPF Project, simple delete the App.xaml and add your own class with a static Main().)
class OrderEntry : System.Windows.Application
{
[STAThread]
static void Main(string[] commandLine)
{
OrderEntry app = new OrderEntry();
app.MainWindow = new WindowMain();
app.MainWindow.Show();
app.Run();
}
}
public partial class WindowMain : System.Windows.Window
{
}
Works fine, but WindowMain has no XAML associated with it.



File -> New Project -> WPF Application.The default WPF project is clean. Don't try to reinvent the wheel. It's already been invented by Microsoft and they know much better than any of us. - Federico BerasateguiApplicationDefinition, and a defaultWindow, which can be removed. There is no "magic" at all. - Federico BerasateguiApplication.Run()is defined inPresentationFramework.dll. - Federico BerasateguiMain()method is generated inApp.g.i.cswhich is autogenerated by theBuild Actionof theApp.xamlfile. Why do you care about any of that? If you don't want that, remove theApp.xamlfile altogether, and define theMain()method yourself. - Federico Berasategui