using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using System.Xml;
using System.Windows.Markup;

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

            // XAML-Datei mit Button-Objekt laden
            XmlReader xr = XmlReader.Create("Button.xaml");
            Button btn = (Button)XamlReader.Load(xr);

            // Button in Benutzeroberfläche einfügen und mit Ereignishandler verbinden
            grid1.Children.Add(btn);
            btn.Click += ButtonOnClick;
        }

        public void ButtonOnClick(object sender, RoutedEventArgs args)
        {
            MessageBox.Show("Danke!");
        }
    }
}
