Загрузка данных


    Title="MainWindow" Height="400" Width="300">
<Grid x:Name="MainRoot" Background="AliceBlue" Cursor="">
    <Grid.RowDefinitions>
        <RowDefinition />
        <RowDefinition />
        <RowDefinition />
        <RowDefinition />
        <RowDefinition />
    </Grid.RowDefinitions>
    <Grid.ColumnDefinitions>
        <ColumnDefinition />
        <ColumnDefinition />
        <ColumnDefinition />
        <ColumnDefinition />
    </Grid.ColumnDefinitions>
    <TextBlock Grid.Row="0" Grid.Column="0" Grid.ColumnSpan="4" x:Name="textlabel" FontFamily="Yu Gothic UI Semibold" FontSize="36"/>
    <Button Grid.Column="0" Grid.Row="1" FontWeight="Bold" FontSize="36" FontFamily="Yu Gothic UI Semibold">1</Button>
    <Button Grid.Column="1" Grid.Row="1" FontFamily="Yu Gothic UI Semibold" FontSize="36" FontWeight="Bold">2</Button>
    <Button Grid.Column="2" Grid.Row="1" FontFamily="Yu Gothic UI Semibold" FontSize="36">3</Button>
    <Button Grid.Column="0" Grid.Row="2" FontSize="36" FontFamily="Yu Gothic UI Semibold">4</Button>
    <Button Grid.Column="1" Grid.Row="2" FontFamily="Yu Gothic UI Semibold" FontSize="36">5</Button>
    <Button Grid.Column="2" Grid.Row="2" FontFamily="Yu Gothic UI Semibold" FontSize="36">6</Button>
    <Button Grid.Column="0" Grid.Row="3" FontFamily="Yu Gothic UI Semibold" FontSize="36">7</Button>
    <Button Grid.Column="1" Grid.Row="3" FontFamily="Yu Gothic UI Semibold" FontSize="36">8</Button>
    <Button Grid.Column="2" Grid.Row="3" FontFamily="Yu Gothic UI Semibold" FontSize="36">9</Button>
    <Button Grid.Column="0" Grid.Row="4" FontFamily="Yu Gothic UI Semibold" FontSize="36">0</Button>
    <Button Grid.Column="1" Grid.Row="4" FontSize="36" FontFamily="Yu Gothic UI Semibold">=</Button>
    <Button Grid.Column="2" Grid.Row="4" FontFamily="Yu Gothic UI Semibold" FontSize="36">AC</Button>
    <Button Grid.Column="3" Grid.Row="4" FontFamily="Yu Gothic UI Semibold" FontSize="36">/</Button>
    <Button Grid.Column="3" Grid.Row="3" FontSize="36" FontFamily="Yu Gothic UI Semibold">*</Button>
    <Button Grid.Column="3" Grid.Row="2" FontFamily="Yu Gothic UI Semibold" FontSize="36">-</Button>
    <Button Grid.Column="3" Grid.Row="1" FontFamily="Yu Gothic UI Semibold" FontSize="36">+</Button>
</Grid>



public partial class MainWindow : Window
{
    public MainWindow()
    {
        InitializeComponent();
        foreach(UIElement el in MainRoot.Children)
        {
            if (el is Button)
            {
                ((Button) el).Click += Button_Click;
            }
        }
    }

    private void Button_Click(object sender, RoutedEventArgs e)
    {
        string str = (string)((Button)e.OriginalSource).Content;
        if (str == "AC")
        {
            textlabel.Text = "";
        }
        else if (str == "=")
        {
            string a = new DataTable().Compute(textlabel.Text, null).ToString();
            textlabel.Text = a;
        }
        else textlabel.Text += str;


    }
}