【问题标题】:GridSplitter to Resize from Right - Odd BehaviourGridSplitter 从右侧调整大小 - 奇怪的行为
【发布时间】:2014-01-02 23:08:26
【问题描述】:

使用 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>

奇怪的是,只有向右拖动才有效,而且大小几乎以相反的方式发生。

【问题讨论】:

  • 遇到完全相同的问题here

标签: wpf xaml grid gridsplitter


【解决方案1】:

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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-06-09
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多