Main Window.xaml C# with Example



Main Window.xaml C# with Example

 // A simple WPF application, written without XAML.
using System;
using System.Windows;
using System.Windows.Controls;
namespace WpfAppAllCode
{
// In this first example, you are defining a single class type to
// represent the application itself and the main window.
class Program : Application
{
[STAThread]
static void Main(string[] args)
{
// Handle the Startup and Exit events, and then run the application.
Program app = new Program();
app.Startup += AppStartUp;
app.Exit += AppExit;
app.Run(); // Fires the Startup event.
}
static void AppExit(object sender, ExitEventArgs e)
{
MessageBox.Show("App has exited");
}
static void AppStartUp(object sender, StartupEventArgs e)
{
// Create a Window object and set some basic properties.
Window mainWindow = new Window();
mainWindow.Title = "My First WPF App!";
mainWindow.Height = 200;
mainWindow.Width = 300;
mainWindow.WindowStartupLocation = WindowStartupLocation.CenterScreen;
mainWindow.Show();
}
}
} 

0 Comment's

Comment Form

Submit Comment