using System;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Input;
using System.Windows.Media;
class MainClass : Window
{
[STAThread]
public static void Main()
{
Application app = new Application();
app.Run(new MainClass());
}
public MainClass()
{
StackPanel stack = new StackPanel();
Content = stack;
for (int i = 0; i < 10; i++)
{
Button btn = new Button();
btn.Name = i.ToString();
btn.FontSize += 10;
btn.Content = "Button " + btn.Name + " says 'Click me'";
btn.Click += ButtonOnClick;
stack.Children.Add(btn);
}
}
void ButtonOnClick(object sender, RoutedEventArgs args)
{
Button btn = args.Source as Button;
MessageBox.Show("Button " + btn.Name + " has been clicked",
"Button Click");
}
}