ソースコード
App.xaml
<Application x:Class="HelloWorld.App" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" StartupUri="MainWindow.xaml"> </Application>
MainWindow.xaml
<Window x:Class="HelloWorld.MainWindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Title="MainWindow" Height="300" Width="300"> <Grid> <Grid.RowDefinitions> <!-- 「会話の履歴」が残りのスペースを占有する --> <RowDefinition Height="*" /> <!-- スペースをすべて占有しないように制約する --> <RowDefinition Height="Auto" MinHeight="50" MaxHeight="150" /> </Grid.RowDefinitions> <Grid.ColumnDefinitions> <!-- 「会話の履歴」が残りのスペースを占有する --> <ColumnDefinition Width="*" /> <ColumnDefinition Width="Auto"/> </Grid.ColumnDefinitions> <GridSplitter Margin="0, 0, 0, -2" Height="5" ResizeDirection="Rows" ResizeBehavior="CurrentAndNext" Grid.Row="0" Grid.ColumnSpan="2" VerticalAlignment="Bottom" HorizontalAlignment="Stretch" /> <TextBlock Grid.Row="0" Grid.Column="0" Grid.ColumnSpan="2" MinWidth="0" Text="こんにちは。" Background="Aqua" Margin="5" /> <TextBox Grid.Row="1" MinWidth="0" Text="ひさしぶり。" Background="Pink" Margin="5" /> <Button Grid.Row="1" Grid.Column="1" MinWidth="0" Margin="5">送信</Button> </Grid> </Window>
参考
GridSplitter クラス (System.Windows.Controls)
Grid コントロールの行間または列間の領域を再配分するコントロールを表します。
【WPF】GridSplitterを使用する上でのほんの些細な注意点。 | 創造的プログラミングと粘土細工
GridSplitterを使用する上でのほんの些細な注意点を紹介します。 ...