2016-04-28 49 views
0

看來我不能用GridSplitter調整大小下一個項目。這裏是XAML:GridSplitter下一步調整大小

<Grid> 
    <!-- this works --> 
    <Grid Background="Gray" HorizontalAlignment="Left"> 
     <Grid.ColumnDefinitions> 
      <ColumnDefinition Width="100" /> 
      <ColumnDefinition Width="auto" /> 
      <ColumnDefinition Width="auto" /> 
     </Grid.ColumnDefinitions> 
     <GridSplitter Grid.Column="1" Width="10" ResizeBehavior="PreviousAndNext" /> 
    </Grid> 
    <!-- this doesn't --> 
    <Grid Background="Gray" HorizontalAlignment="Right"> 
     <Grid.ColumnDefinitions> 
      <ColumnDefinition Width="auto" /> 
      <ColumnDefinition Width="auto" /> 
      <ColumnDefinition Width="100" /> 
     </Grid.ColumnDefinitions> 
     <GridSplitter Grid.Column="1" Width="10" ResizeBehavior="PreviousAndNext" /> 
    </Grid> 
</Grid> 

和演示:

注意什麼留下Grid可以調整,而正確的有一些問題。你可以嘗試給xaml看看我的意思。

我應該怎麼做才能使下一個項目調整大小工作?

回答

1

我把它通過改變ColumnDefinition寬度

<Grid> 
    <Grid Background="Gray" HorizontalAlignment="Left"> 
     <Grid.ColumnDefinitions> 
      <ColumnDefinition Width="100" /> 
      <ColumnDefinition Width="auto" /> 
      <ColumnDefinition Width="*"/> 
     </Grid.ColumnDefinitions> 
     <GridSplitter Grid.Column="1" Width="10" ResizeBehavior="PreviousAndNext" /> 
    </Grid> 
    <Grid Background="Gray" HorizontalAlignment="Right"> 
     <Grid.ColumnDefinitions> 
      <ColumnDefinition Width="*" /> 
      <ColumnDefinition Width="auto" /> 
      <ColumnDefinition Width="100" /> 
     </Grid.ColumnDefinitions> 
     <GridSplitter Grid.Column="1" Width="10" ResizeBehavior="PreviousAndNext" /> 
    </Grid> 
</Grid> 

和另一種變體,我喜歡的工作更多:

<Grid> 
    <Grid Background="Gray"> 
     <Grid.ColumnDefinitions> 
      <ColumnDefinition Width="100" /> 
      <ColumnDefinition Width="auto" /> 
      <ColumnDefinition Width="*" /> 
      <ColumnDefinition Width="auto" /> 
      <ColumnDefinition Width="100" /> 
     </Grid.ColumnDefinitions> 

     <GridSplitter Grid.Column="1" Width="10" ResizeBehavior="PreviousAndNext" /> 

     <Border Grid.Column="2" Background="Gold"/> 

     <GridSplitter Grid.Column="3" Width="10" ResizeBehavior="PreviousAndNext" /> 
    </Grid> 
</Grid> 
+0

你有沒有解釋爲什麼'*'工作和'auto'也在工作,但只在一個方向?我的問題是在不可調整大小的列中有* optional *內容,這就是爲什麼它必須是'auto'。不確定它是否能用'*'工作,給我一分鐘。 – Sinatr

+0

@Sinatr,我只能猜測這是分離器的內部邏輯。由於網格具有左右水平對齊,所以'*'變成'自動' – ASh

相關問題