2011-07-26 221 views
3

当在DataGrid(或具有列的任何其他控件)中重新调整列的大小时,该列中的ColumnSpan跨越具有Width =“*”的ColumnDefinition,同时嵌套ScrollViewer会在ColumnDefinitions重新调整大小的时候出现这种奇怪的行为。DataGrid列重新调整大小,重新调整大小Grid ColumnDefinitions

下面的XAML示例显示了此行为。

有谁知道这里发生了什么,为什么发生?该ColumnDefinitions甚至有固定的宽度,但他们仍然被重新调整大小...

<Window.Resources> 
    <x:Array x:Key="PointList" Type="{x:Type Point}"> 
     <Point X="1" Y="4" /> 
     <Point X="2" Y="3" /> 
     <Point X="3" Y="2" /> 
     <Point X="4" Y="1" /> 
    </x:Array> 
</Window.Resources>  

<ScrollViewer HorizontalScrollBarVisibility="Auto" VerticalScrollBarVisibility="Auto"> 
    <Grid> 
     <Grid.ColumnDefinitions> 
      <ColumnDefinition Width="100" /> 
      <ColumnDefinition Width="200" /> 
      <ColumnDefinition Width="*" /> 
     </Grid.ColumnDefinitions> 
     <Grid.RowDefinitions> 
      <RowDefinition Height="Auto" /> 
      <RowDefinition Height="*" /> 
     </Grid.RowDefinitions> 

     <Label Background="Red" Grid.Column="0" Content="Something 1" /> 
     <Label Background="Green" Grid.Column="1" Content="Something 2" /> 
     <Label Background="Blue" Grid.Column="2" Content="Something 3" /> 

     <DataGrid ItemsSource="{StaticResource PointList}" Grid.Column="0" Grid.Row="1" Grid.ColumnSpan="3" /> 
    </Grid> 
</ScrollViewer> 

回答

0

我会假设这是因为测量的ScrollViewer在两个维度上的报告无限空间(与您的滚动条设置即是)中。