Hi, I've been learning C# for a while now so I decided to finally tackle WPF, and I feel like a beginner again. Only a few pages into my studies I tried to replicate the code in my book but it just doesnt seem to produce the output that the book shows.

Im trying to create a simple window with a button as its only content, however the button is not showing up at all, just the window.

Also, the title of the window that pops up is "MainWindow" even though I called the constructor with the title argument "My First WPF Program"

Can somebody please help me resolve those 2 issues.

Code:
using System;
using System.Windows;
using System.Windows.Controls;


namespace WPF_Practice
{
    class Program : Application
    {
        [STAThread]
        int Main()
        {
            Program app = new Program();
            app.Startup += AppStartup;   
            app.Exit += AppExit;         
            app.Run();

            return 0;
        }

        static void AppStartup(object sender, StartupEventArgs arg)
        {
            MainWindow themain = new MainWindow("My First WPF Program", 400, 300);
            
        }

        static void AppExit(object sender, ExitEventArgs arg)
        {
            Console.WriteLine("Application is now exiting");
        }
    }

    class MainWindow : Window  
    {
        private Button exitbutton = new Button();

    
        public MainWindow(string t, int h, int w)
        {
            exitbutton.Click += exitbutton_Click;  
            exitbutton.Content = "Close Window";
            exitbutton.Height = 25;
            exitbutton.Width = 100;

            this.Content = exitbutton; // Setting content of the Window to a single button. 

            this.Title = t;
            this.Height = h;
            this.Width = w;
            this.WindowStartupLocation = WindowStartupLocation.CenterScreen;
            this.Show();
        }

        private void exitbutton_Click(object sender, RoutedEventArgs arg)
        {
            this.Close();
        }
    }

}