Grid动态内容

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
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;

namespace WpfApplication1
{
    /// <summary>
    /// MainWindow.xaml 的交互逻辑
    /// </summary>
    public partial class MainWindow : Window
    {
        public MainWindow()
        {
            InitializeComponent();
        }

        public void check_long(object sender, RoutedEventArgs e)
        {
            btn_prev.Content = "<< long btn prev";
            btn_next.Content = "long btn next >>";
            check_box_long.Content = "short";
            text_box.Text = "XAML中的属性和事件 XAML中的属性和事件 XAML中的属性和事件 XAML中的属性和事件 XAML中的属性和事件 XAML中的属性和事件 XAML中的属性和事件";
        }

        public void uncheck_long(object sender, RoutedEventArgs e)
        {
            btn_prev.Content = "prev";
            btn_next.Content = "next";
            check_box_long.Content = "long";
            text_box.Text = "XAML中的属性和事件";
        }
    }
}
<Window x:Class="WpfApplication1.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        Title="MainWindow" Height="350" Width="525">
    <Grid Margin="10">
        
        <Grid.RowDefinitions>
            <RowDefinition Height="*"></RowDefinition>
            <RowDefinition Height="Auto"></RowDefinition>
        </Grid.RowDefinitions>
        
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="Auto"></ColumnDefinition>
            <ColumnDefinition Width="*"></ColumnDefinition>
        </Grid.ColumnDefinitions>
        
        <StackPanel Grid.Row="0" Grid.Column="0">
            <Button Name="btn_prev">prev</Button>
            <Button Name="btn_next">next</Button>
            <CheckBox Name="check_box_long" Checked="check_long" Unchecked="uncheck_long">long</CheckBox>
        </StackPanel>
        
        <TextBox Name="text_box" Grid.Row="0" Grid.Column="1" TextWrapping="WrapWithOverflow" Grid.RowSpan="2">aaa bbb ccc</TextBox>
        <Button Grid.Row="1" Grid.Column="0">close</Button>
        
    </Grid>
</Window>