GridSplitter to Resize from Right - Odd Behaviour

血红的双手。 提交于 2019-12-08 02:23:32

问题


Using Kaxaml, resizing from the left works as expected.

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

However when trying something similar on the right it behaves very differently.

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

Oddly only dragging right works and the size happens in an almost inverse manner.


回答1:


For the first column change Width="*" to Width="Auto".



来源:https://stackoverflow.com/questions/20880272/gridsplitter-to-resize-from-right-odd-behaviour

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!