GridSplitter从右边 - 奇怪的行为调整大小

时间:2014-01-02 09:55:11

标签: wpf xaml grid gridsplitter

使用Kaxaml,从左侧调整大小可以正常工作。

<Page
  xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
  xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
  <Grid>  

  <Grid HorizontalAlignment="Left">
    <Grid.ColumnDefinitions>
      <ColumnDefinition Width="Auto"></ColumnDefinition>
      <ColumnDefinition Width="Auto"></ColumnDefinition>
      <ColumnDefinition Width="Auto"></ColumnDefinition>
    </Grid.ColumnDefinitions>


    <GridSplitter Grid.Column="1" Width="5" Background="DarkGray" HorizontalAlignment="Right"></GridSplitter>

    <Rectangle Grid.Column="0" Fill="Red" Height="100"/>
    <Rectangle Grid.Column="1" Fill="Yellow" Height="100"/>
    <Rectangle Grid.Column="2" Fill="Green" Height="100"/>
  </Grid>

  </Grid>
</Page>

然而,当在右边尝试类似的东西时,它表现得非常不同。

<Page
  xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
  xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
  <Grid>  

  <Grid HorizontalAlignment="Right">
    <Grid.ColumnDefinitions>
      <ColumnDefinition Width="Auto"></ColumnDefinition>
      <ColumnDefinition Width="Auto"></ColumnDefinition>
      <ColumnDefinition Width="Auto"></ColumnDefinition>
    </Grid.ColumnDefinitions>


    <GridSplitter Grid.Column="1"  Width="5" Background="DarkGray" HorizontalAlignment="Left"></GridSplitter>

    <Rectangle Grid.Column="0" Fill="Red" Height="100"/>
    <Rectangle Grid.Column="1" Fill="Yellow" Height="100"/>
    <Rectangle Grid.Column="2" Fill="Green" Height="100"/>
  </Grid>

  </Grid>
</Page>

奇怪的是,仅拖动正确的工作,并且大小以几乎相反的方式发生。

1 个答案:

答案 0 :(得分:0)

第一列将Width="*"更改为Width="Auto"