GridSplitter从右侧调整 - 奇数行为 [英] GridSplitter to Resize from Right - Odd Behaviour
本文介绍了GridSplitter从右侧调整 - 奇数行为的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
< Page
xmlns =http: //schemas.microsoft.com/winfx/2006/xaml/presentation
xmlns:x =http://schemas.microsoft.com/winfx/2006/xaml>
<网格>
< Grid HorizontalAlignment =Left>
< Grid.ColumnDefinitions>
< ColumnDefinition Width =Auto>< / ColumnDefinition>
< ColumnDefinition Width =Auto>< / ColumnDefinition>
< ColumnDefinition Width =Auto>< / ColumnDefinition>
< /Grid.ColumnDefinitions>
< GridSplitter Grid.Column =1Width =5Background =DarkGrayHorizontalAlignment =Right>< / GridSplitter>
< Rectangle Grid.Column =0Fill =RedHeight =100/>
< Rectangle Grid.Column =1Fill =YellowHeight =100/>
< Rectangle Grid.Column =2Fill =GreenHeight =100/>
< / Grid>
< / Grid>
< / Page>
然而,当尝试类似的东西时,它的行为会有很大的不同。
< Page
xmlns =http://schemas.microsoft.com/winfx/2006/xaml/presentation
xmlns: X = http://schemas.microsoft.com/winfx/2006/xaml >
<网格>
< Grid HorizontalAlignment =Right>
< Grid.ColumnDefinitions>
< ColumnDefinition Width =Auto>< / ColumnDefinition>
< ColumnDefinition Width =Auto>< / ColumnDefinition>
< ColumnDefinition Width =Auto>< / ColumnDefinition>
< /Grid.ColumnDefinitions>
< GridSplitter Grid.Column =1Width =5Background =DarkGrayHorizontalAlignment =Left>< / GridSplitter>
< Rectangle Grid.Column =0Fill =RedHeight =100/>
< Rectangle Grid.Column =1Fill =YellowHeight =100/>
< Rectangle Grid.Column =2Fill =GreenHeight =100/>
< / Grid>
< / Grid>
< / Page>
奇怪的是,只有拖动正确的作品和大小以几乎相反的方式发生。
解决方案
对于第一列更改宽度=*
至宽度=自动
。
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.
解决方案
For the first column change Width="*"
to Width="Auto"
.
这篇关于GridSplitter从右侧调整 - 奇数行为的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文