この基本的なレイアウトのウィンドウがあります。
<Window x:Class="GridStuffs.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>
<Grid.RowDefinitions>
<RowDefinition />
<RowDefinition />
</Grid.RowDefinitions>
<Button Grid.Row="0" Click="TopButtonClick" VerticalAlignment="Stretch">Top</Button>
<Button Grid.Row="1" Name="_bottomButton">Bottom</Button>
</Grid>
これは、2つのボタン「上」と「下」を表示しているだけで、それぞれがウィンドウ内で等しい垂直方向のスペースを占めています。
一番上のボタンをクリックすると、以下が実行されます。
private void TopButtonClick(object sender, RoutedEventArgs e)
{
if (_bottomButton.Visibility == Visibility.Collapsed)
{
_bottomButton.Visibility = Visibility.Visible;
}
else
{
_bottomButton.Visibility = Visibility.Collapsed;
}
}
...下のボタンの表示を折りたたみと表示の間で切り替えます。
私がしたいのは、下のボタンが折りたたまれたときに、上のボタンのサイズを変更してウィンドウ全体に表示することです。実際に起こっているのは、下のボタンが非表示になっていることですが、上のボタンは元のサイズを保持しています。
質問:下部のボタンが折りたたまれているときに上部のボタンを展開してウィンドウを埋めるには、どのようなwpf / xamlの魔法を使用する必要がありますか?