0

レイアウトの問題を表示したいこのコードがあります。

<Window x:Class="DataGrid.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        WindowStartupLocation="CenterScreen"
        ResizeMode="CanResize" SizeToContent="WidthAndHeight"
        Title="Example" MinHeight="250" MinWidth="250">
   <Grid>
      <Grid.RowDefinitions>
         <RowDefinition Height="Auto" />
         <RowDefinition Height="Auto" />
      </Grid.RowDefinitions>
      <Grid.ColumnDefinitions>
         <ColumnDefinition Width="Auto" />
         <ColumnDefinition Width="*" />
      </Grid.ColumnDefinitions>

      <Rectangle Grid.Row="0" Grid.Column="0" Fill="Beige" Width="400" Height="250" Margin="4" />
      <Rectangle Grid.Row="0" Grid.Column="1" Fill="Green" Width="400" Height="250" Margin="4" />
      <ScrollViewer Grid.Row="1" Grid.Column="0" Grid.ColumnSpan="2" HorizontalScrollBarVisibility="Auto" VerticalScrollBarVisibility="Auto">
         <Rectangle Fill="LightCoral" Width="4000" Height="100" />
      </ScrollViewer>
   </Grid>
</Window>

長方形は、データグリッドやグラフなどのオブジェクトを表します。最初の 2 つの長方形は小さいですが、3 番目の長方形は非常に長くなる可能性があるため、scrollviewer 内にあります。問題は、スクロールバーが表示される前に、この長い長方形がダイアログをフルスクリーンに拡大することです。

2 つの小さな四角形(グリッドの最初の行)に基づいてのみダイアログの幅を設定し、スクロールビューアーを長い四角形に適用したいと思います。ただし、SizeToContent = "WidthAndHeight"小さな長方形はサイズが異なる可能性があるため、 を保持する必要があります。

レイアウトを編集する方法についてのアイデアはありますか?

4

0 に答える 0