雇用主から次のwpfレイアウトが提供されています。複数のネストされたスタックパネルを利用します。メインウィンドウの四隅から一定の距離を置いてスタックパネル内にあるデータグリッドを固定しようとしています。また、親ウィンドウのサイズが原因で一部が非表示になっているデータがグリッドに含まれている場合は常に、スクロールバーが表示されることになっています。スクロールバーは、不要な場合は非表示にする必要があります。
データグリッドとスタックパネルの幅を[自動]に設定して、幅がいっぱいになり、水平スクロールバーと垂直スクロールバーが希望どおりに動作するようにしました。しかし、グリッドには必要な高さがありません。
しかし、データグリッドのheightプロパティを自動に設定しようとすると、水平スクロールバーと垂直スクロールバーの両方が非表示になり、データが非表示になります。データグリッドの高さプロパティを固定サイズに設定し、ウィンドウのサイズが変更されるたびに更新しようとしましたが、スクロールバーがまだ非表示になっていますが、これを修正するにはどうすればよいですか?
<UserControl x:Class="WpfApplication1.UserControl1"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
mc:Ignorable="d"
d:DesignHeight="441" d:DesignWidth="300">
<Grid>
<StackPanel Margin="0" Name="stackPanel1">
<ListBox Height="100" Name="listBox1" Width="253" />
<Button Content="Button" Height="23" Name="button1" Width="256" Click="button1_Click" />
<StackPanel Name="stackPanel2">
<StackPanel Height="34" Name="stackPanel3" Width="249" />
<DataGrid AutoGenerateColumns="False" Name="dataGrid1" Height="282" />
</StackPanel>
</StackPanel>
</Grid>
</UserControl>
<Window
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:my="clr-namespace:WpfApplication1" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" mc:Ignorable="d" x:Class="WpfApplication1.MainWindow"
Title="MainWindow" Height="502" Width="525" StateChanged="Window_StateChanged">
<Grid Margin="0">
<my:UserControl1 x:Name="userControl11" Loaded="userControl11_Loaded" />
</Grid>
</Window>