using System;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Media;

namespace ZdarzeniaTrasowane
{
    /// <summary>
    /// Interaction logic for MainWindow.xaml
    /// </summary>
    public partial class MainWindow : Window
    {
        public MainWindow()
        {
            InitializeComponent();
        }

        private void button_Click(object sender, RoutedEventArgs e)
        {
            Button przycisk = (sender as Button);

            Button b = new Button();
            b.Content = "Nowy przycisk";
            b.HorizontalAlignment = HorizontalAlignment.Left;
            b.VerticalAlignment = VerticalAlignment.Top;
            double w = przycisk.Width - 20;
            double h = przycisk.Height - 20;
            if (w > 0 && h > 0)
            {
                b.Width = w;
                b.Height = h;
                b.Click += button_Click;
                przycisk.Content = b;
            }
            else przycisk.IsEnabled = false;
            b.Click += button_Click;
            przycisk.Content = b;
            e.Handled = true;
        }
    }
}
